Submission

Status:

----------

Subtask/Task Score:

0/100

Score: 0

User: por

Problemset: Dvaravati-LCS

Language: cpp

Time: 0.004 second

Submitted On: 2026-03-16 21:27:24

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp [ 605][605];

int main(){

    string a,b;
    cin>>a>>b;
    string ans;
    for(int i=1;i<=a.size();i++){
        for(int j=1;j<=b.size();j++){
            if(a[i-1]==b[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 x=a.size();
    int y=b.size();
    while(x!=0&&y!=0){
        if(a[x-1]==b[y-1]){
            ans+=a[x-1];
            x--;
            y--;
        }
        else if(dp[x-1][y]>dp[x][y-1]){
            x--;
        }
        else{
            y--;
        }
    }
    for(int i=ans.size();i>=0;i--){
        cout<<ans[i];
    }
    cout<<endl;
    cout<<dp[a.size()][b.size()]<<endl;
    int k = a.size()/2;
    if(dp[a.size()][b.size()]>=k){
        cout<<"y";
    }
    else{
        cout<<"n";
    }
    return 0;
}