ICFPC2010åæ¦è¨
åé¡è¨å®ã¨ã㯠http://d.hatena.ne.jp/ku-ma-me/ ãè¦ãã°ããã¨ãã¦ã
éææ¥21:00ã23:00
åé¡èªã¿ã¿ã¤ã ããã£ã±ãããããªãããä¸çªä¸ã«æåã«ããã¹ããã¨ãæ¸ãã¦ãã£ãã®ã§ã0ãéãã°ããã£ã½ãããµã¼ããæ»ã«æãã¦ã¦å ¨ãéããªãããã£ã¨åå¿ããã£ãã¨ãã«ã¯ãã§ã«ç»é²ããã¦ããã£ã¦åºãã
ããã¯ããã¨ãã¦ã次ã¯åè·¯ãç解ããã¨ãããã¨ã ã£ãã®ã§ãã¾ãåè·¯ã®ãã©ã¼ããããæ¨æ¸¬ãã¦ãé©å½ã«ä½ã£ãåè·¯ãéãå§ãããã22022022022022022ããè¿ãã¦ããåè·¯ãè¦ã¤ãã¦ããããã³ãã«ãªããã¨æã£ãããæéåãã§é»è»ã«ä¹ã
åææ¥
å¸°å® ãã¦ãé©å½ã«åè·¯ãä½ã£ã¦éãã¤ããä½æ¥ãç¶ãããçµè«ã¨ãã¦ã次ã®ãããªåè·¯ãèããã°ã²ã¼ãã®åä½ãæ¨æ¸¬ã§ãããã¨ãåãã£ãã
X +---+ | | | +-*-*-+ | | | | +-*-*-+ | | | | | +---+ A | +---+ | | | +-*-*-+ | | | | +-*-*-+ | | | | | +---+ B | +---+ | | | +-*-*-+ | | | | +-*-*-+ | | | | | +---+ C
æåã«ï¼ã²ã¼ãã®ãéã£ã¦Aã®åºåã調ã¹ã¦ã次ã«ï¼ã²ã¼ãã®ãéã£ã¦Bã®åºåã調ã¹ã¦ããç¹°ãè¿ãã°å ¥åã¨åºåã®ãã¢ã¯ãããã§ãå¾ãããããããå·¦å³å転ããåè·¯ã«å¯¾ãã¦ãè¡ã£ã¦ã
å·¦å ¥åºå 02120112100002120 00100202221110100 01221000201200221 02110011002121022 00122120010101102 01211021122222000 02101101211111211 00112002101201012 å³å ¥åºå 22022022022022022 21202210221202210 20221022020221022 22102202212020221 21121022111202211 20202202021120202 22120221202112022 21112020221102210
ããããã£ã¨çºãã¦ãã°ãå·¦ã«2ãå ¥åããã¨ãã«å·¦ããã¯0,1,2ã®å ¨éããåºã¦ãã®ã§ã
in | out 2 ? | 0 X 2 ? | 1 ? 2 X | 2 ?
ããè¦ãã¨ãã2->0ãã®ç´å¾ã«ã2->2ããããã®ã§ãXãçãããã¨ãåãããéä¸ã§è¨ç®ééããè«å¤§ã«ããã®ã§æéãããã£ããã©ãè¨é²ã«ããã¨1:30ããã«ã²ã¼ãã¯ç¢ºå®ããããã ã
åè·¯ä½æ
ã¨ããããã§ãä»åº¦ã¯ä»»æã®åºåãåºããåè·¯ãä½ãæ¹æ³ãèããªãã¨ãããªãããã ããæåã«èããã®ã¯å¸¸ã«0ãåºãåºæ¬åè·¯ãä½ãããããã¨ãæã£ã¦ã¿ãããããã ãã©ãã©ãé ãã²ãã£ã¦ãæ³åãã§ããªãã®ã§ãããã¦ãã£ã¨ç´æ¥ã«ããæ¹æ³ãæãã¤ããã
ã¨ãããããåè·¯å ¨ä½ããã®å½¢ã«åºå®ãããã¨ã«ãã
inp | +---+ | |Y | +-*-*-+ | | | | +-*-*-+ | | |X | | +---+------X | | æ®ãã®åè·¯ out +------Y'
ãã®åè·¯ã¯inpã¨outã®tritåãä¸ããããã¨ãã inp[0] = out[0] ãªãã°è§£ããã£ã¦ã
Y = 0::Y' inp[0] = out[0] X[0] = inp[0]Ã0-1 Y[k] = inp[k]-out[k] X[k] = inp[k]ÃY[k]-1
ã®ããã«ãXã¨Y'ã®tritåãå®å ¨ã«æ±ºå®ã§ãããããããY'ã®åã®é·ãã¯outã®é·ããã1çãã
ãã£ã¦ãinpããoutãåºãåè·¯ãä½ãåé¡ã¯inp[0]=out[0]ã®ã¨ãã¯ã1çãå ¥åºåã®åé¡ã«åç´åã§ããã
åæ§ã« inp[0]-2=out[0]ã®ã¨ãã¯ãã¡ãã£ã¨æ¹é ã㦠Y = 2::Y' ã«ããã°ããã®ã§ã
+---+ +-------+ | | | | | +-*-*-+ | | | | | | +-*-*-+ | | | | | +---+ | | | | +-+ | | | | +---+ | | | | | +-*-*-+ | | | | | | +-*-*-+ | | | | | | | +---+---+ inp | | | +---+ | | |Y | +-*-*-+ Y' | | +-*-*-+ | |X | +-----X | out
ã¨ã¤ãªãã¨ãY = 2::f(Y') ã¨ãªãããã®fãå ¨åå°ã«ãªãããã«ç¹ããªãã¨ãããªãã®ã§å³åºåã使ããªãã®ã§ãã
ããã§key prefixã¯éã£ããæã®7æåããããã®ã¾ã¾å¯ã¦èµ·ãã¦ãå¤ã«ãªã£ããè»ãã©ã¼ããããç 究ãããã¨ã«ããã
æ¥ææ¥
åå2æãããã«ãã£ã¨è»ã®ãã©ã¼ããããã»ã¼ããã£ããå¼ãç¶ãçæã®è§£æãåå3æåã«æåã®çæãééããããã®æç¹ã§ç°¡åãªè»ã«ãããã給油ãã¦ãã°ãã£ã¨ç¹æ°ãé«ãã£ããã ãã©ãã¡ã¤ã³ã®åé¡ãèãå§ãã¦ãã¾ã£ããä¸äººã§ãã£ã¦ãã¨ãããããªãããã
ãã®ã¸ãã§ããµã³ãã«ã®è»ã解ããã¨ãããããã£ã±ãç解ã§ããªãããããªè»è§£ããã®ãï¼ã©ã³ãã ã«è¡åãçæããããã¡ãã£ã¨ããå¤ç°ãå ãã¦ãå ¨ãçãã«è¿ã¥ãã¦ãããããªæ°é ããªãã9æåã¾ã§æ©ãã§å ¨ã解決ããªãã£ãã®ã§å¯ãã
21æããã«èµ·ãã¦ã大è¡è»ã«çµ¦æ²¹ããä»äºããã¾ããããã®ãã¨ãµã³ãã«è»ã®è§£ãæ¹ãèããã®ã ããããããåé¡ã®åºç¤ç¥èããªãã®ã§ãã£ã±ãããããªããéç·å½¢ã®æé©ååé¡ã¨ããã£ããã¨ãªããã
23æã«ããããã¦WORKINGãè¦ããããããããã«æéåãã