fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. string a, b;
  6. cin >> a >> b;
  7. int A=a.length(), B=b.length();
  8. int LCS[A+1][B+1]={};
  9.  
  10. for (int i=3; i<=a.length(); i+=3)
  11. for (int j=3; j<=b.length(); j+=3)
  12. if (a.substr(i-3, 3)==b.substr(j-3, 3))
  13. LCS[i][j]=LCS[i-3][j-3]+1;
  14. else
  15. LCS[i][j]=max(LCS[i-3][j], LCS[i][j-3]);
  16. cout << LCS[A][B];
  17. }
Success #stdin #stdout 0s 5320KB
stdin
가장긴증가하는부분수열문제
stdout
Standard output is empty