LCS
LCS ãæ±ãã DP ã®ç·´ç¿ãéåæ¬ã®åé¡ãªã®ã§ã³ã¼ãã®ã¿ã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ 2 ã¤ã®æåå ãä¸ããããã ã®é¨ååã§ã ã®é¨ååã§ããããããªæååã®é·ãã®æ大å¤ãæ±ããã å¶ç´ ã³ã¼ã #include <bits/stdc++.h> using namespace std; int main() { string S, </bits/stdc++.h>â¦
ããã«ã JOI ã«ãããã¡ãªæ·»åã®æã¡æ¹ããã DPï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ è±å°æåã¨è±å¤§æåãããªãé·ã ã®æåå ã¨ãé·ã ã®æåå ãä¸ãããããã¾ã 0 ä»¥ä¸ 3 以ä¸ã®æ´æ° ãä¸ããããã 次ã®æ¡ä»¶ãæºããæåå ã®é·ãã®æå°å¤ãæ±ããã ã¯ãè±â¦
LCS (Longest Common Subsequence) ã«ããä¼¼ã DPï¼ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ (æ訳) é·ã ã®æ´æ°å ã¨ãé·ã ã®æ´æ°å ãä¸ããããããããã«ä»¥ä¸ã®æä½ãç¹°ãè¿ããã¨ã§ãè¦ç´ æ°ãçãããªãããã«ãããã A ã®è¦ç´ ã 1 ã¤é¸ãã§åé¤ãã B ã®è¦ç´ ã 1â¦
çµæ§æ©ãã ï¼ï¼ï¼ åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ é·ã ã®æåå ã¨ãé·ã ã®æåå ãä¸ããããã ã®é£ç¶ããé¨åæåå ã¨ã ã®é£ç¶ããé¨åæåå ãã¨ã£ãã¨ãã ã¨ããã ã®èããããæ大å¤ãæ±ããã å¶ç´ èããã㨠åç´ã«ããããã®é¨åæååãæ¢ç´¢ãâ¦
å ±éé¨ååã«é¢ããåé¡ï¼ï¼ï¼ï¼ï¼ æé·å ±éé¨åååé¡ã¯æåã ãã©ãä»åã¯å ±éé¨ååãæ°ãä¸ããåé¡ã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ 2 ã¤ã®æ°å ãä¸ããããã 㨠ã®å ±éé¨ååãä½éãããããæ±ããã ãã ãã ã ããæãåã£ã¦ã§ããæååãåããã®â¦
é¢ç½ãã£ã åé¡ã¸ã®ãªã³ã¯ åé¡æ¦è¦ æåå ãä¸ããããããããããæååã®ä¸ã® æåãèªç±ã«å¤æ´ãããã¨ãã§ããã ãããã¦å¾ãããæååã¨ããããå転ããæååã® LCS (æé·å ±éé¨åå) ã®é·ãã¨ãã¦èããããæ大å¤ãæ±ããã å¶ç´ èããã㨠â¦