Re:AtCoderã§éè²ã«ãªãã¾ã§ã«ãã£ãäºã¨ããã¾ã¨ãã
ååã¾ã§ã®ãããã
1.ãã®è¨äºãåèã«ãã¦æ°´è²ã«ãªãã¾ããã
2.ãã®è¨äºãåèã«ãã¦éè²ã«ãªãã¾ããã
3.ãã®è¨äºãåèã«ãããæ°´è²ã«æ»ãã¾ããã
ã¯ããã«
ããã«ã¡ã¯ã7/1ã®ARC100ã§ç¡äºéè²ã«æ»ãäºãã§ãã¾ããããã£ãã¼ï¼
æµç³ã«äºåé£ç¶ã§ã¯ã½è¨äºãçæããã®ãè¯ããªãã®ã§ããã®è¨äºã§ã¯ARC100ã®åå è¨ã¨èå¯ãæ¸ãã¾ãã
è¨é²
ARC100ã§ã¯176ä½ã§ããã©2086ãã¬ã¼ãã¯1544ãã70ä¸ãã£ã¦1614(highest)ã«ãªãã¾ããã
CEã®2å®ã§1000ç¹ãæåºæ
å ±ã¯ãããªæãã§ãã
Submission #2775185 - AtCoder Regular Contest 100
Submission #2775990 - AtCoder Regular Contest 100
ã³ã³ãã¹ãä¸ã®çµé
ã³ã³ãã¹ãéå§ã¨åæã«Cãèªã¿ã¾ãããåé¡æãé£ããã£ãã®ã§ç解ããã¾ã§ã«3åãããããã£ã¦ãã¾ãã¾ããã
ã§ã解æ³ã¯ãããããã¾ããã§ããâ¦
ã¡ãã£ã¨èãã¦bã®å¤ã決ããæã®æ²ããã®å¤ã®ã°ã©ããå¹ã®ãããªå½¢ã«ãªãäºã¯åãã£ãã®ã§ããããã®ãããªåé¡ã解ãã®ã«ä¾¿å©ãªä¸åæ¢ç´¢ã®ã©ã¤ãã©ãªãæã£ã¦ãã¾ããã§ãã ããªããã
æ¤ç´¢ãããã¦èª¿ã¹ã¦ãã³ã¼ãããã®ã¾ã¾è¼ã£ã¦ãããµã¤ãã¯(æ¤ç´¢ä¸ä½ã®æ°ãã¼ã¸ã§ã¯)ç¡ãã£ãããèªåã§æ¸ãã¨ãã°ãããããªã®ã§è«¦ãã¾ãã ããã¾ã§ã§ç´10å(ã¯ï¼)
ããããDã¨Eã®åé¡æãèªãã ã®ã§ããããããããããããªãâ¦
Dã¯JOIã«ããã¤ãé¡é¡(ããã¤ãã«åã£ã¦æå°å¤ãæ大å¤ãæ±ããåé¡)ããã£ãã®ã§ãã¨ãããããã£ã¡ã®åé¡ãè¦ãªããé²ãã¦ããã¾ããã
é¡é¡ã¨ãã¦æãå½ãã£ãã®ãæ°´ããããããã¼ã ã¯ã¼ãã³ãªã©ã§ãåè
ã¯åãåããæã®æå°å¤ã¨æ大å¤ã®å·®ãå¾è
ã¯åãåå²ããæã®æå°å¤ã®æ大åãæ±ããåé¡ã§ããã
æ°´ããããã®æ¹ã¯ã¨ã¦ãä¼¼ã¦ããåé¡ã ã¨æã£ãã®ã§è§£èª¬ãè¦ãã®ã§ãããã©ãããè¨ç®éçã«éã«åããªãããã ããªãã
ãã¼ã ã¯ã¼ãã³ã¯O(NlogN)ãããã§è§£ãããããããã¡ãã®è§£èª¬ã¹ã©ã¤ããè¦ãäºã«ãã¾ããã
ã¨ããããããã«è¼ã£ã¦ãããæå°å¤ã決ãæã¡ãã¦ç´¯ç©åã«ã¶ããããã¦è²ªæ¬²ããããã¿ãããªæ¹æ³ã試ãã¦ã¿ã¾ãããã"3 2 4 1 5"ã®ãããªã±ã¼ã¹ã§WAãåãã¦ãã¾ãæ念
ããããæå°å¤ã®æ大åã¨æå°å¤ã¨æ大å¤ã®å·®ã¯å
¨ãå¥ç©ãªã®ã§ãããªãã®ã¬ãã§ããâ¦
æ³å®è§£ã ã£ããçãä¸ã®å¤ãåºå®ãã¦ã«ã¶ããorãããã¨ããã¯æãã¤ããã®ã§ãã(è² ãæãã¿)ã2ã¤ã«åå²ããä¸ã§ããã«ååã«ãªãããã«åãã¨çããåºããã¨ããé¨åã«æ£å½æ§ãæããããªãã£ã(ãããã¬ã)ã®ã§è«¦ãã¾ãã è¦è¿ãã¨ã¬ãã°ã£ããã ãªãå
ã¨ããäºã§Dã¯è«¦ãã¦Eåé¡ã¸åããäºã« ãã®æç¹ã§NoSubã®ã¾ã¾50åããããçµéãã¦ããã®ã§ãææªãã®ã¾ã¾æªæåºã¬ã¼ãå¤å0ã§ãããããªã¨ãæã£ã¦ã¾ãã
è¦ãç®ã¨å¶ç´ãè¦ãã¨ãªãã¨ãªãbitDPã£ã½ãâ¦ããã£ã½ããªãï¼ ã¿ãããªãæ°æã¡ã ã£ãã®ã§ã¨ããããbitDPãããæ¹éã«æ±ºãã¾ããã
ã¾ãã¯ä»®ã«K=6ã®ã±ã¼ã¹ã«ã¤ãã¦èãã¦ã¿ã¾ãã
Kã¯2é²è¡¨è¨ã§110ãªã®ã§ã2é²è¡¨è¨ã§i={000,010,100,110}ã«ãªãAiã®ä¸ããå¤ã®å¤§ããäºã¤ã®åãåºãã°ãããããªæ°ããã¾ãã
ãããããã®èãæ¹ã ã¨i,j=(1,5)ã«ãªããããªãã¢ãé¸ãã æã«ç·åãæ大ã«ãªããããªæ°åãæ¥ãæã«æ£ããçããåºãäºãã§ãã¾ããã
ããã§ãKãå°ãããã®ããåãã¦ãã£ã¦ãã®ç´¯ç©maxãåãäºã«ãã¾ããç´¯ç©maxãåãèãã¯ãµã³ãã«2ããµã³ãã«3ãåããã¦ãããã¡ã«èªç¶ã¨æ¹§ãæ°ããã¾ãã
ããã¾ã§ã§ãåKã«ã¤ãã¦(i or j) and ~K ã0ã«ãªããããª(i,j)ã®çµã®ãã¡Ai+Ajãæ大ã®ãã®ã®ãã¢ãåãã°ããäºãåããã¾ããããèå¿ã®(i,j)ã®ãã¢ã®æ±ãæ¹ããããã¾ããã
ã¨ããããdp[i][j]:kããi and ~k == 0ãæºããAiã®ä¸ã§jçªç®ã«å¤§ããå¤ãã¨ãã¦ã¿ã¾ãã
ãã®å ´åãdpé
åã®æ·»åjã®é¨åã¯2åããåããªãã¦ãããæ·»åiã®é¨åã¯2Nååãå¿
è¦ãããã®ã§ãO(2N*(ä¸åã®é·ç§»ã«ãããè¨ç®é))ãããã§DPãã§ãããã§ãã
èå¿ã®é·ç§»ã«ã¤ãã¦ã¯é
ãDPã§ãã0<=K<NãæºããåKã«ã¤ãã¦ãdp[i|(1<<K)]ã®é¨åã«dp[i][0]ã¨dp[i][1]ãå²ãè¾¼ã¾ãããã¿ãããªæãã®äºãèãã¦ã¿ã¾ãã
ããdp[i|(1<<K)][0]ããdp[i][0]ã®æ¹ã大ããã£ããdp[i|(1<<K)][1]=dp[i|(1<<K)][0]ã¨ãã¦dp[i|(1<<K)][0]=dp[i][0]ã¨ããã°ããã§ãããdp[i][1]ã«ã¤ãã¦ãåæ§ã«é·ç§»ãã§ãã¾ãã
ããããã®ãããªåãæ¹ãããã¨ãA0ãæ大ã«ãªããããªã±ã¼ã¹ã§dp[8][0]ã¨dp[8][1]ã®ä¸¡æ¹ãA0ã«ãªã£ã¦ãã¾ããããªåé¡ãèµ·ããã¾ããåãå¤ãæ¥ãæã«åé¿ãããããªãif(dp[i|(1<<K)][0] != dp[i][0])ã®ããã«ããã°ããæ°ããã¾ãããæ°åã®è¤æ°ã®è¦ç´ ãåãå¤ãåã£ã¦ããå ´åã«åé¡ãèµ·ããã¦ãã¾ãã¾ãã
ããã§ãdp[i][j]:kããi and ~k == 0ãæºããAiã®ä¸ã§jçªç®ã«å¤§ããå¤ã®indexãã¨å¤ãã¦éè¤å¯¾å¿ããã¦ã¿ãã¨ç¶ºéºã«è§£æ±ºãããäºãã§ãã¾ãã
ããã¾ã§æ¸ãã¦ãµã³ãã«ãåããããå¾ã¯æåºã®ã¿ããªã®ã§ããéå§80åãéããå¾ã®åSubmitã¯å¿èã«æªãã£ãâ¦
ããã§è½ã¡ããææªå¤ªé½ã ã£ãã®ã§ãéã£ãæã¯æ¬å½ã«å®å¿ãã¾ããã
ãã¦ããã®ã¾ã¾ã ã¨E<CDã§è² ãã¦ãã¾ãã®ã§Cãéãäºã«ãã¾ããCE>CDãªã®ã§ããããéããã°é ä½ãã¬ã¼ããçä¸ããªã¯ãâ¦ï¼
è½ã¡çãã¦èãç´ãã¦ãã¾ãä¸åæ¢ç´¢ã£ã½ããªãâ¦ã£ã¦æãã ã£ãã®ã§ãã¤ã³ã¿ã¼ãããããä»äººã®ã©ã¤ãã©ãªãçãã§ããäºã«ãã¾ããã
å¤å®é¢æ°ã®å®è£
é¨åã¯ã¨ã¦ã楽ã§ãã°ãããäºã¯ãªãã£ãã®ã§ãããåæã§ã®bã®ç¯å²è¨å®ã[0,INF)ã¨ãã«ããã¨æå¾ã®ãµã³ãã«ãåããæ®éã«WAãåãã®ã§æ³¨æãã¾ãããâ¦è¨ç®éã«ãä½è£ãããã®ã§[-1018,1018]ãåæç¯å²ã«æã£ãä¸åæ¢ç´¢ããã¾ããã
ããã§Cãéãã¦2å®ãCD2å®ã®äººããé«ãç¹æ°ãªã®ã§é ä½ãçä¸ãã§ç²¾ç¥ã«åªããã£ãã§ã 0å®å¤ªé½ãããªãã¦æ¬å½ã«ããã£ã
ãããã«
ã¾ãæ°´è²ã«è½ã¡ããè¨äºãæ¸ãäºå®ã§ã ã楽ãã¿ã«ï¼