Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: PIP3_PP
Problemset: Dvaravati-LCS
Language: cpp
Time: 0.003 second
Submitted On: 2026-03-13 15:16:23
#include<bits/stdc++.h>
using namespace std;
int main(){
string s1,s2,s3 = "";
cin >> s1 >> s2;
int n = s1.size(),mx = 0;
vector<vector<int>> DP(n + 1 ,(vector<int> (n + 1,0)));
for(int i = 1 ; i <= n ; i++){
for(int j = 1 ; j <= n ; j++){
if(s1[i-1] == s2[j-1]){
DP[i][j] = DP[i-1][j-1] + 1;
}else{
DP[i][j] = max(DP[i-1][j],DP[i][j-1]);
}
}
}
int i = n , j = n;
while(i > 0 && j > 0){
if(s1[i-1] == s2[j-1]){
s3 += s1[i-1];
i--;j--;
}else if(DP[i-1][j] > DP[i][j-1]) i--;
else j--;
}
reverse(s3.begin(),s3.end());
cout << s3 << "\n" << DP[n][n] << "\n";
if(DP[n][n] >= n/2) cout << 'y';
else cout << 'n';
}