Manacheræ³
ãã¿ã³ã³ãã¹ããªã®ãã¨æããããåé¡é¢ç½ãã¦ããã® D åé¡ã¯åå¼·ã«ãªã£ããçã決ãæã¡ã®äºåæ¢ç´¢ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ è±å°æåãããªãé·ã ã®æåå ãä¸ããããã ãã®æååã«ã¤ã㦠åã®ã¯ã¨ãªã«çãããã åã¯ã¨ãªã§ã¯æ´æ°å¤ ãä¸ãããâ¦
åæãªåé¡ãªã¹ãã«ï¼ï¼ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ à ã®ã°ãªãããä¸ããããåã»ã«ã«ã¯ 0 ã 1 ã®å¤ãæ¸ããã¦ããã ä»ã縦æ¹åã¨æ¨ªæ¹åã«åãç®ãå ¥ãã¦ã4 ã¤ã®é·æ¹å½¢ã«åãã¦ãããããã®é·æ¹å½¢ã 180 度å転ãããæä½ãè¡ãã ãã®ã¨ãã«ãåè¡ååâ¦
ããªãã®ç·´ç¿ï¼ï¼ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æåå T ãä¸ããããã以ä¸ã®æ¡ä»¶ãæºããæé·ã®é·ãã®æåå S (å転ãããã®ã S' ã¨ãã) ãæ±ãã: S + S'.substr(1) + S.substr(1) + S'.substr(1) + S.substr(1) + ... ã®æåã® æåã ã¨ä¸è´ãâ¦