æå¾ å¤
å ¬å¼è§£èª¬ã®æ¹ãã·ã³ãã«ã ã£ãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ã®é å ã¨ãæ´æ° ãä¸ããããã ã®é£ç¶ãã åã®è¦ç´ ãããªãåºéï¼ éãããï¼ãã©ã³ãã ã«é¸ã³ãããã«ãã®åºéãã©ã³ãã ã·ã£ããã«ããã æçµçãªé åã®è»¢åæ°ã®æå¾ å¤ã mod 998244353 ã§æ±â¦
ãåæ°ã®æå¾ å¤ãã¯ã(k å以ä¸ã®ç¢ºç) ã®ç·åã«ä¸è´ããï¼ï¼ ãã¨ã¯æåãªã åã®ä¸æ¬¡é¢æ°ã®ç©ã¯äºåæ¨ã®ãããªè¨ç®é åºã§ ã®è¨ç®éã§æ±ããããã¨ããè©±ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ è²ã ã§ãããããªé´ä¸ã æãã¤ããããããã 2 種é¡ä»¥ä¸ããã ãããâ¦
è¡åç´¯ä¹ããããããã°ã«æããã£ãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ã®é å ãä¸ããããã以ä¸ã®æä½ã åè¡ãã ãé¸ã㧠㨠ã swap ãã æä½å㯠éãèããããããããããã«ã¤ãã¦ã® ã®ç·åã 998244353 ã§å²ã£ãä½ããæ±ããã å¶ç´ èããã㨠ã®æå¾ â¦
ã³ã³ãã¹ãä¸ã«ã¯éããããªãã£ããæµç³ã«ç²ãã¦ãã¦é ãåããªãã£ã......ããã¯ã¡ã¢ä»£ããã«è¨ãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æ´æ°å¤ ãç確çã§åºã¦ããã«ã¼ã¬ãããããã å æã¨å¾æã交äºã«ã«ã¼ã¬ãããåã ãã¹ã¦ã®æ´æ°å¤ãæã£ããçµäºã§ãã ãã§â¦
é¤åçï¼ å¦ã³ã®å¤ãåé¡ã ã£ããSubset Convolution ã®æ¹ã¯ã¡ãã£ã¨é å¼µã£ã¦ãã®å¾å¾©ç¿ããã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é ç¹çªå·ã ã§ããã°ã©ã ããããæåã辺㯠1 æ¬ããªãã ä»¥ä¸ ä»¥ä¸ã®å¤ãããªããµã¤ãº ã® 2 ã¤ã®æ°å 㨠ãããã ä»ãããã 2 ã¤â¦
æå DP ã§è¿·èµ°ãã¦ãæå¾ å¤ã®ç·å½¢æ§ã使ã£ã¦ ã¾ã§æ¥ãããã§ããPolynomial Taylor Shift ãªã解æ³ããããããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åã®ãã£ã³ãã£ããã£ã¦ãåãã£ã³ãã£ã®è²ã¯æ£ã®æ´æ° ã§è¡¨ããã¦ããã å ã«å¯¾ãã¦ã åã®ãã£ã³ãã£ãã åã®ãâ¦
EDPC A - Frog 1 ã¨ã»ã¨ãã©åã DP ã§è§£ãã¾ããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ä½åã ã§ããã¢ã³ã¹ã¿ã¼ã 1 ä½ãã¾ããé«æ©åã¯ã¢ã³ã¹ã¿ã¼ã«å¯¾ããã¢ã³ã¹ã¿ã¼ã®ä½åã 1 以ä¸æ®ã£ã¦ããéãç¹°ãè¿ãæ»æãè¡ãã¾ãã é«æ©å㯠1 åã®æ»æã§ã ã®ç¢ºçã§ã¢ã³ã¹â¦
ã·ãã·ãã¿ããã« 2 ã¤æãã¨æ¶ãããããªå¯¾è±¡ç©ã®æ°ãä¸ãåé¡ããããæãåºãã drken1215.hatenablog.com åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ (æ訳) "B", "W", "?" ã®ã¿ãããªãé·ã ã®æååãä¸ãããã ( ã¯å¶æ°)ã"?" ã« "B", "W" ãå²ãå½ã¦ãæ¹æ³ã®ãã¡ã"Bâ¦
å¤ãªã¨ããã§ããããªãããã«ããã... åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ã®é å ãä¸ããããããã¾ããããã®é åã®åè¦ç´ ã«å°ãã¤ãã¦ãããã¨ãèããããã ãããå°ã®ã¤ããè¦ç´ ãå·¦ããé ã«å調å¢å ã¨ãªãããã«ä¸¦ãã§ãããã¨ããæ¡ä»¶ã常ã«æºããå¿ è¦ãããâ¦
æåããæå¾ å¤ã®ç·å½¢æ§ãã使ãã®ããªã¨æã£ã¦è¿·èµ°ãã... D 㯠DP ã® D ã ã£ãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ è¢ã®ä¸ã«é貨ã æãé貨ã æãé 貨ã æå ¥ã£ã¦ãããè¢ã®ä¸ã«ããããããã®ç¨®é¡ã®ç¡¬è²¨ã 100 æã«ãªãã¾ã§ä»¥ä¸ã®æä½ãç¹°ãè¿ãã æä½ï¼è¢ã®ä¸â¦
é¢ç½ãããã åæã§å¼·é£çµæåå解 (SCC) ããããªãã®ãç½ ããããSCC èªä½ã¯èå¯éç¨ã¨ãã¦ã¯æªããªãããã ãã©ãSCC ã㦠DP...ã¨èããã¨å¤§å¤ã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é ç¹ã®åç´æåã°ã©ããä¸ããããã以ä¸ã®æä½ãã°ã©ãã空ã«ãªãã¾ã§ç¹°ãè¿ãâ¦
é è² diff åé¡ãèªåã§è§£ãã¦å¬ããã(ä¿®æ£ï¼èµ¤è²ã«ãªã£ã) åé¡ã¸ã®ãªã³ã¯ editorial åé¡æ¦è¦ åç¹ãä¸å¿ã¨ããåå¾ 1 ã®åå¨ä¸ã« åã®ç¹ ããã (åè§ãå ¥åã¨ãã¦ä¸ãããã)ã ãããã®ç¹ããã©ã³ãã ã« 3 ç¹é¸ãã§ã§ããä¸è§å½¢ã®å å¿ã®åº§æ¨ã®æå¾ å¤ãâ¦
ãããã¤å³ã®å¿ç¨åé¡ï¼ åé¡ã¸ã®ãªã³ã¯ editorials åé¡æ¦è¦ é ç¹æ° ã®å¸å¤è§å½¢ããã£ã¦ããã®å é¨ã« åã®ç¹ãä¸ãããããå¸å¤è§å½¢ã®å é¨ã«ä¸æ§ã©ã³ãã ã«ç¹ãæã¤ã¨ãã以ä¸ã®å¤ã®æå¾ å¤ãæ±ããã ããã®ç¹ ãã åã®ç¹ã¾ã§ã®è·é¢ã®æå°å¤ããäºä¹ããå¤â¦
æã ãã£ã¦ããç©åã²ã¼ãåæã«å¤é å¼ã²ã¼ã§ããã£ãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åã®åºé ãä¸ããããããããã®åºéããä¸æ§åå¸ã«ãããã£ã¦ç¹ãã¨ã£ã¦ãã (é£ç¶å¤)ã åç¹ã®åº§æ¨ã®æ大å¤ã®æå¾ å¤ã ããããå¤ (æ´æ°å¤ã«ãªã) ã 1000000007 ã§å²ã£ãâ¦
æ»ã DP ã·ãªã¼ãºã®ãã¬ã¼ãã³ã° åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ (å ¥åå½¢å¼ã¯å¤å°æ¹å¤) æ£ã®æ´æ° ã¨ã åã®æ£ã®æ´æ° ãä¸ãããããããããã©ã³ãã ã·ã£ããã«ããã ãæºããæå°ã® ãèããããã®å¤ã®æå¾ å¤ãæ±ãã (è¦æ±ç²¾åº¦ã¯ )ã å¶ç´ èããã㨠åè¦ç´ ã«â¦
ã²ã¼ã¯ç¢ºãã«é¢ç½ããããããªãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æ´æ°å ãä¸ãããã åããé·ã ã®æ´æ°å ã¯ã å ã«ã¤ãã¦ç¬ç«ã«ã ãæºããæ´æ°ã®ä¸æ§åå¸ããã©ã³ãã ã«é¸ã°ããã ãã®ã¨ãã ã®æé·å¢å é¨ååã®é·ãã®æå¾ å¤ã mod 1000000007 ã§è¨â¦
ã³ã³ãã¹ãä¸ã« ã¾ã§å°ãã¦ãããªãããæå¾è©°ããããªãã£ãã®ã¯åçã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ã®é å ã¨ã2 以ä¸ã®æ´æ° ãä¸ããããã ã«å¯¾ãã¦é ã«ä»¥ä¸ã®æä½ãè¡ãã ãã©ã³ãã ã·ã£ããã«ãã åã®æä½å¾ã«å¾ãããé åã®è»¢åæ°ã®æå¾ å¤ããmod 9982â¦
確ãã«ããã§ã ãµãã®ã©ã¹åã«ããããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ 人ã®é¸æãè·é¢ ã®ã¬ã¼ã¹ãèµ°ãã 人ç®ã¯ããã©ã«ãã§ã¯è·é¢ 1 èµ°ãã®ã« ç§ãããã ã¹ã¿ã¼ãããè·é¢ã ã®ã¨ããã«ã¢ã¤ãã ããããåã¢ã¤ãã ã¯åé¸æã«å¯¾ãã¦ç¬ç«ã«ã確ç ã§æ¸é (è·é¢ â¦
å®è£ ãã¨ã°ã¨ã°ã®ã¨ã°ã ãã©ãå®ã¯ãªãã¨ãé 延è©ä¾¡ã»ã°æ¨ããå¿ è¦ãªãã¦ãæ®éã®ã»ã°æ¨ã ãããã°è§£ãã¦ãã¾ãï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åã®æ´æ° ã«å¯¾ãã¦å®ã¾ãé ã次ã®ããã«å®ç¾©ãã: ã®é¨åéåãé¸ã¶ éãã®æ¹æ³ããä¸æ§ã©ã³ãã ã«é¸ãã§ãããã«â¦
æä½ã åè¡ã£ãçµæãæ±ããç³»ãè¦ææèãããã©å æãããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ã¨çªå·ã®æ¯ããã åã®ãã¼ã«ããã£ã¦ãåæç¶æ ã§ã¯ãããã ã®ä½ç½®ã«ããã以ä¸ã®æä½ã åè¡ããæçµçãªåãã¼ã«ã®åº§æ¨ã®æå¾ å¤ãããããæ±ããã åæä½ã¯ åã®â¦
æå¾ å¤ã®ç·å½¢æ§ï¼ï¼ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åã®ãµã¤ã³ããå·¦ããå³ã«ä¸åã«ä¸¦ã¹ã¦ããã çªç®ã®ãµã¤ã³ãã¯ç®ã ã¨ãªã£ã¦ãã¦ãããããå½ç¢ºçã«åºãã é£æ¥ãã åã®ãµã¤ã³ããé¸ãã§ããããç¬ç«ã«æ¯ã£ãã¨ããåºãç®ã®åè¨ã®æå¾ å¤ã®æ大å¤ãæ±ãããâ¦
æå¾ å¤ã®ç·å½¢æ§çãªã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ä½ã®ã¹ã©ã¤ã ããããã ã®ä½ç½®ã«ãã (ãããã¯å調å¢å )ã 以ä¸ã® éãã®ã¹ã©ã¤ã åä½éç¨ããããã«ã¤ãã¦ãã¹ã©ã¤ã ã®ç§»åè·é¢ã®ç·åãèããããã®ç·åè·é¢ã®ç·åãæ±ããã1000000007 ã§å²ã£ããã¾ãã§â¦
ããããã®ã«æ £ãã¦è¡ãããã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®ç·åä¸ã«ãã©ã³ãã ãªåºéã åã¨ã£ãã¨ãã®ãåºéã æ¬ä»¥ä¸éãªã£ã¦ããé¨åã®é·ãã®æå¾ å¤ãæ±ãã (998244353 ã§å²ã£ãä½ãã®å½¢å¼ã§)ã ãªããåºéã®ã©ã³ãã ãªé¸ã³æ¹ã¨ã¯ãç·åãã 2 ç¹ãâ¦
ããã ã£ãï¼ï¼ï¼ drken1215.hatenablog.com ãã¡ããé«éã¼ã¼ã¿å¤æã¯ãããªãã¦ãæç´ãªå é¤åçã§éã«åãã åé¡æ¦è¦ æ´æ° ãä¸ããããã空㮠vector ããã£ã¦ ä»¥ä¸ ä»¥ä¸ã®æ´æ°ã®ä¸ããä¸æ§ã©ã³ãã ã« 1 ã¤é¸ã³ã ããã vector ã« push ãã ãã®ã¨ã â¦
0. ãããã¼ã° æå¾ å¤ã«ã¾ã¤ããæåäºå®ã¨ãã¦ã以ä¸ã®ãã¨ãä¸è¬ã«ããç¥ããã¦ãã¦ã競ããã§ãéå»ä½åº¦ãåºé¡ä¾ãããï¼ï¼ï¼ 確ç ã§æåãã試è¡ãæåããã¾ã§ç¶ããã¨ããæåããã¾ã§ã®åæ°ã®æå¾ å¤ã¯ ã§ãã åã®åç©ãã©ã³ãã ã«åºåãããã³ã³ãâ¦
æå¾ å¤ã«é¢ããã»ã³ã¹ãã¡ãã£ã¨æ±ããããåé¡ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é«æ©åã¯ãã¹ãã±ã¼ã¹ã ã±ã¼ã¹ãã Yes/No å¤å®åé¡ã«å¯¾ãã¦ãã½ã¼ã¹ã³ã¼ããæåºããã¨ãã å㧠TLE ãã¦ãæ®ãã® åã¯æ£è§£ãã¾ããã ããã§ã åã«ã¤ãã¦ã¯ 100ms ã§æ£è§£ããæ®â¦
ã©ã³ãã ã¦ã©ã¼ã¯ãªåé¡ï¼ å®æ°ä¿æ°ã®é£ç«æ¹ç¨å¼ã®ç·´ç¿ã« åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é ç¹ã®éã¿ä»ãç¡åã°ã©ããä¸ããããããã ãèªå·±ã«ã¼ããå«ã¿å¾ã (å¤é辺ã¯ãªã)ãäºé ç¹ ãæå®ããã¦ãã¦ã ãã ã¸ã¨ã©ã³ãã ã¦ã©ã¼ã¯ã«ãã£ã¦è¾¿ãçãããã ãã ãâ¦
ç©åãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ãµã¤ãº ã®é·æ¹å½¢ã®ç´ã¨ããããããµã¤ãºã®å°ãããµã¤ãº ã®é·æ¹å½¢ã®ç´ã 2 æããã¾ãã 2 æã®å°ãããµã¤ãºã®ç´ããããããã大ãããµã¤ãºã®ç´ã®ä¸ã«å å«ãããç¯å²å ã§ã©ã³ãã ã«é ç½®ãã¾ã (ãã®ä½ç½®ã¯é£ç¶é)ã ãã®ã¨â¦
ãã®ã·ã³ãã«è¨å®ã§ãã®æ·±ã¿...ãããï¼ï¼ï¼ ã ã¯é åãçµåãã表ããã®ã¨ããã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·æ¹å½¢ã®ç´ããã£ã¦ãæ°´å¹³æ¹åã®åãç·ã ç®æãåç´æ¹åã®åãç·ã ç®æããã ç®æã®åãç·ãã ç®æé¸ãã§é ã«åã£ã¦è¡ã éãã®æ¹æ³ããããã«â¦
ã°ãªããç³»ã¯è¦ææèãããã©è§£ãã¦ããã£ã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ äºæ¬¡å ããããä¸ãããã¦ãåãã¹ã¯ åº ('.') å£ ('#') ãã ('*') ã® 3 ã¤ã®å±æ§ããããã¹ã¿ã¼ã ('s') ã¨ã´ã¼ã« ('g') ãè¨å®ããã¦ãã¦ãããããåºå±æ§ã§ããã s ãã g ã¸æéâ¦