é¢ç½ãã£ãï¼ è§£èª¬ AC ããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é ç¹æ° ãè¾ºæ° ã®åç´ç¡åã°ã©ããä¸ããããããã®ã°ã©ãã®è¾ºã®é åã§ãã£ã¦ã次ã®æ¡ä»¶ãæºãããã®ã 1 ã¤æ±ããï¼ãªããã° -1 ãåºåããï¼ã ãæ¡ä»¶ã é ç¹æ° ãè¾ºæ° ã®ã°ã©ãã«å¯¾ãã¦ãä¸è¨ã®é åºâ¦
é¢ç½ãã£ãï¼ ã«ã¿ã©ã³æ°çãªãã®ãç»å ´ããã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ å¶ç´ èããã㨠ã¾ãããã«ããã£ããã¨ã¯ã ã®ä¸ã«ã1 ã 2 å以ä¸ãã£ã¦ã¯ãã¡ ã®ä¸ã«ã1 ãæ«å°¾ä»¥å¤ã®å ´æã«ãã£ã¦ã¯ãã¡ ã¨ãããã¨ã ã£ããããããã¨ã ã¯æ¬¡ã®ããããã®å½¢ã«ãªâ¦
B åé¡ã¨ãã¦ã¯æããã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ã¬ã¼ãã£ã³ã°ã ã®äººã åã³ã³ãã¹ãã«åå ããã åç®ã®ã³ã³ãã¹ãã§ã¯ãDiv. ã®ã³ã³ãã¹ãã«åå ãã¦ãããã¬ã¼ãã£ã³ã°æ´æ°å¯¾è±¡è ã§ããã°ãã¬ã¼ãã£ã³ã°ã¯ ã ãå ç®ãããï¼è² å¤ãããããï¼ã ARC Div.â¦
ãã 150 ç¹ãªã®ã¯è§£éä¸è´ã ããé£ããã¨æããã©ãDifficulty ã 19 ã¨ãããä½ãã®ãé©ãï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ä»ãæå» 0 ã§æ°´ã¯ 0 L ãã¾ã£ã¦ããã ããããæå» ã«ããããæ°´ã L 注ãããã ãªããæ°´ã 1 L 以ä¸ããã¨ããæå»ã 1 çµéãããâ¦
for æã®åºæ¬åé¡ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æåå ãä¸ããããã ã®åæåã«ã¤ãã¦ãæå ã§ãªããã®ããã¹ã¦æå ã«ç½®ãæãããã®ãåºåããã èããã㨠for æã®ç·´ç¿åé¡ã¨ãããã for æãç¨ãã¦ã ã®åæåã«ã¤ãã¦ã ã§ãããã©ãããå¤å®â¦
è¿å¹´ã® B åé¡ã§ã¯æãç°¡åãããããªãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æå .ã@ ãããªãé·ã ã®æåå ãä¸ãããããå¾ãããé ã« åã® @ ã . ã«å¤ãããã®ãåºåããã èããã㨠for æãç¨ãã¦ãæ·»åã ã¨ããéé ã«åãã¦ããã S[i] == '@' ã®ã¨ã â¦
ã¡ããã¨æ´çããã®ã¯å¤§å¤ã ãè½ã¡çãã¦æ´çãããã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æåå ãä¸ããããã ã "11/22 æåå" ã§ãããã©ãããå¤å®ããã 11/22 æååã§ããã¨ã¯ãæå 1, /, 2 ããã®é ã«ä¸¦ãã§ãã¦ã1 㨠2 ã®åæ°ãçãããã®ãããâ¦
åé¡æããããããæ¸ãæ¹ããã¦ãããã©ããè¦ããã«ãããããã¨ï¼ãã¨ããè¨ãæããã§ããã¨ããã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æå ., @ ãããªãé·ã ã®æåå ãä¸ããããã@ ãå·¦ããé ã« åã ã . ã«æ¸ãæããã æ¸ãæãããã¨ã®æååã«å«ã¾ããâ¦
ã¨ããå¶ç´ãããã«ãæªããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ 1 ä»¥ä¸ 20 以ä¸ã®æ´æ°ãããªããé·ã ã®æ°å ãä¸ããããã ãã®æ°åã®é¨åå (é£ç¶ã§ãªãã¦ãã) ã§ãã£ã¦ãä»»æã®æ´æ°ã«ã¤ãã¦ããã®é¨ååã«å«ã¾ããåæ°ã 0 åã¾ã㯠2 åã§ãããã®ãèããã â¦
éååãå¦ã¼ãï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åã®æåå ããã®é ã«ä¸ããããã ååºã®æååã«å¯¾ãã¦ããã®æ·»åãåºåããã å¶ç´ 解説 0-indexed ã§èãã¾ããã¤ã¾ããæååã ã¨ãã¾ãï¼åºåããã¨ãã«ã¯ 1 ã足ãã¾ãï¼ã ã¾ãã¯è¨ç®éã®ãã¨ãèããã«â¦
éè¨å¦çããä¸ã§ãå度大ããé ã«ã½ã¼ãããåé¡ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åã®æåå ãä¸ããããã ãã®åã«ä¸å以ä¸åºç¾ããåèªãããã®åºç¾åæ°ã®å¤ãé ã«ä¸¦ã¹ãã¨ã çªç®ã®åèªãåºåããï¼ä¸æã«æ±ºã¾ããªãå ´å㯠"ambiguous" ã¨åºåããï¼ã å¶ç´ â¦
ã¡ãã£ã¨å·¥å¤«ãå¿ è¦ãªæã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã æ£æ´æ°å ã¨ãæ£ã®æ´æ° ãä¸ããããã æ°åã®åºéã§ãã£ã¦ãç·åã ã§å²ã£ãä½ãã¨ãåºéå ã«å«ã¾ããè¦ç´ ã®åæ°ã¨ãçãããã®ã®åæ°ãæ±ããã å¶ç´ èããã㨠çµæ§ããããããè½ã¡çãã¦æ¡ä»¶ãâ¦
ä¸æã«å¼å¤å½¢ãããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æ£ã®æ´æ°ãããªããµã¤ãº ã®æ°å ãä¸ããããã次ã®æ¡ä»¶ãæºããçµ ã®åæ°ãæ±ããã å¶ç´ èããã㨠æ¡ä»¶ãä¸æè°ã ãæ®é㯠ããã ã®æ¹ã大ãããã¨ãå¤ãã®ã«ã ã¨ãªãæ¡ä»¶ãåãã¨ã¯ã ãã¦ããã®æã®æ°â¦
æ¡ä»¶ãä¸æã«è¨ãæãããï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åã®æ´æ° ãä¸ããããã ãå¹³æ¹æ° ã¨ããæ¡ä»¶ãæºãããããªçµ ã®åæ°ãæ±ããã å¶ç´ èããã㨠ããã¯ãæ¡ä»¶ã®è¨ãæãããé å¼µãåé¡ãã ãå¹³æ¹æ°ãã¨ããæ¡ä»¶ãæ±ããããããã«è¨ãæãããããâ¦
ãåºéã®å¤ã®åããè¦ãããç´¯ç©åãã¨ããï¼ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æ°å ã¨æ´æ° ãä¸ããããã æ°åã®é£ç¶ããåºéã§ãã£ã¦ããã®ç·åã ã«ä¸è´ãããã®ãä½åããããæ±ããã å¶ç´ èããã㨠0-indexed ã§èããã æ°å ã®ç´¯ç©åã ã¨ãããããã®â¦
for æã®ç·´ç¿åé¡ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ãã®çãã 2 ã¤ã®æåå ãä¸ããããã ã«å«ã¾ããåæå '@' ã«ã¤ãã¦ã'a', 't', 'c', 'o', 'd', 'e', 'r' ã®ããããã«ç½®ãå¤ãããã¨ã§ã ãä¸è´ããããã«ã§ããããå¤å®ããã å¶ç´ [tex 1 \le |S| = |Tâ¦
ãããé¢ç½ãåé¡ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åã®æåå ãä¸ããããã ãããã®æååããç°ãªã 2 ã¤ã®æååãé¸ã¶æ¹æ³ã§ãã£ã¦ããããã®æååãäºãã«ã¢ãã°ã©ã ã¨ãªã£ã¦ãããã®ã®åæ°ãæ±ããã å¶ç´ èããã㨠ã¾ãã¯ãåé¡ã®æ¡ä»¶ãããããããâ¦
é£æ³é åã®è¯ãç·´ç¿åé¡ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æ£ã®æ´æ°ãããªãæ°åãè¯ãæ°åã§ããã¨ã¯ãæ°åã«å«ã¾ããä»»æã®æ´æ°å¤ ã«ã¤ãã¦ãæ°åä¸ã« ãã¡ããã© åå«ã¾ãã¦ãããã¨ãããã ä¸ããããæ°å ã«å¯¾ãã¦ãããã¤ãã®è¦ç´ ãåé¤ãããã¨ã§ãããæ°â¦
ç´ æ´ãª map ã®ç·´ç¿åé¡ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ããããã㯠åã®åé¡æ¡ãæã£ã¦ããã åç®ã®åé¡æ¡ã®é£æ度㯠ã§ããã ãããããé ç¹ã ã§ãããã㪠åãããªãåé¡ã»ãããä½ããã¨ã¯å¯è½ãï¼ å¶ç´ èããã㨠é£æ³é å (C++ ãªãã° map) ã®ç·´ç¿åé¡â¦
ããå®ã¯ãã¢ã«ãã¡ãããæåã®å¤æãã¼ãã«ãæç´ã«ä½ããã¨ããç´ æ´ãªæ¹æ³ã解ãããã©ãæå¤ã¨ç²ç¹ã«ãªãããã ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ è±å°æåã®ã¿ãããªãé·ã ã®æåå ãä¸ããããã次㮠åã®æä½ãå®è¡å¾ã®æååãåºåããã ãæä½ã æå â¦
å ´ããã«ã¼ããææã«å ¥ããªãæ¹ãè¯ãå ´åãããã®ããããï¼ ãã¨ãå±é¢ç¶æ ãæ°å¤æ å ±ã«ã¨ã³ã³ã¼ãããããè¿·ã£ããã©ãã¨ã³ã³ã¼ãããªãã¦ãéã£ãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ã¯ãããé«æ©åã¯æ´æ° ã®æ¸ããã æã®ã«ã¼ããæã£ã¦ãã¦ãéæ¨åã¯æ´æ° ã®â¦
å ¬å¼è§£èª¬ã®æ¹ãã·ã³ãã«ã ã£ãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ã®é å ã¨ãæ´æ° ãä¸ããããã ã®é£ç¶ãã åã®è¦ç´ ãããªãåºéï¼ éãããï¼ãã©ã³ãã ã«é¸ã³ãããã«ãã®åºéãã©ã³ãã ã·ã£ããã«ããã æçµçãªé åã®è»¢åæ°ã®æå¾ å¤ã mod 998244353 ã§æ±â¦
é 延è©ä¾¡ã»ã°ã¡ã³ãæ¨ã¨ããã® max_right, min_left ã§æ®´ã£ãï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ ãã¹ ãä¸åã«ä¸¦ãã§ãã¦ãããããè² ã§å¡ããã¦ããã次㮠åã®ã¯ã¨ãªã«çããã ã¯ã¨ãªã¿ã¤ã 1ï¼ãã¹ ã¨è² ãæå®ãããã®ã§ããã¹ ããå§ãã¦ããã¾ãããã¹ã¨åâ¦
å®é¨ãã¦ãããã¡ã«ã·ã³ãã«ãªæ§é ãããã£ãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ è±æåãããªãé·ã ã®æåå ãä¸ããããããã®æååã«å¯¾ãã¦ã次ã®æä½ã åè¡ã£ã¦ã§ããæååãèããã ãæä½ã æåå ã«å¯¾ãã¦ãè±å°æåã¨è±å¤§æåãå ¥ãæ¿ãã¦ã§ããæåâ¦
ã©ã³ã¬ã³ã°ã¹å§ç¸®ã§è§£ãã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ 0 㨠1 ãããªãé·ã ã®æåå ãä¸ããããããã®æååã®ä¸ã§ã®ã1 ã®å¡ãã®ãã¡ãå·¦ãã çªç®ã®ãã®ãã çªç®ã®ãã®ã®å³ã«ç§»åãããã ä¾ï¼"010011100011001" â "010011111000001" å¶ç´ èããã㨠ã¾â¦
åæ©çãªæ§æ解æåé¡ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ "|---|-|----|-|-----|" ã®ãããªãæå '-' ãæå '|' 㧠separate ãããæåå ãä¸ããããã å '-' åºéã® '-' ã®åæ°ãé ã«åºåããã å¶ç´ èããã㨠ããã§ã¯ for æã§è§£ãã¦ã¿ããã次ã®å¤æ°ã管â¦
ã½ã¼ãã使ãããªããããã楽ã ã¨æã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ 6 æ¡ã®æ£ã®æ´æ° ãä¸ããããã ã次ã®æ¡ä»¶ãæºãããã©ãããå¤å®ããã 1 ãã¡ããã© 1 åå«ã 2 ãã¡ããã© 2 åå«ã 3 ãã¡ããã© 3 åå«ã è§£æ³ (1)ï¼1, 2, 3 ã®åæ°ãæ°ããæ¹æ³ for æâ¦
ä¹ ãã¶ãã«é«é£æ度åé¡ã解ãã¦ã¿ãï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ åãã¹ã®å¤ã 0 ã¾ã㯠1 ã§ãã ã°ãªãããèããã ã°ãªãã ã®ãã¹ ããåºå®ããã¦ãããã¨ã¯ã次ã®æ¡ä»¶ãæºãããã¹ã¦ã® ã°ãªããã«ã¤ãã¦ããã¹ ã®å¤ãä¸æã«æ±ºã¾ããã¨ãããã ãã¹ã¦â¦
ã主客転åã»å¯ä¸å解ãã®å ¸ååé¡ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ 1 ãã 9 ã¾ã§ã®æ°åãããªã æ¡ã®æ´æ°å¤ ãä¸ããããã ãã®æ´æ°å¤ã®é£ç¶ããåºéãåãåºãã¦ã§ããæ´æ°å¤ã®ç·åãæ±ãããï¼998244353 ã§å²ããªããï¼ å¶ç´ èããã㨠ãã®æã®åé¡ã§ã¯ã â¦
ãå ¨ä½ã«è¶³ããã®ã¯é£ããããã足ãå¤ãå¥éæã£ã¦ããã¨ããã¹ãã«ï¼ï¼ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ 以ä¸ã® åã®ã¯ã¨ãªã«çããã ã¯ã¨ãªã¿ã¤ã 1ï¼æ°ãã«è¦ç´ 0 ãæ¿å ¥ããï¼éè¤ãããï¼ ã¯ã¨ãªã¿ã¤ã 2ï¼ãã§ã«æ¿å ¥ããã¦ãããã¹ã¦ã®è¦ç´ ã« ã足ã ã¯ã¨â¦