Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: erng

Problemset: Dvaravati-LCS

Language: cpp

Time: 0.003 second

Submitted On: 2026-03-05 18:25:43

#include <bits/stdc++.h>

using namespace std;

string sta, stb, ans;
int sz, cnt, dp[605][605];
vector<char> c;

int main()
{
    cin>>sta>>stb;
    sz=sta.size();
    for (int i=1; i<=sz; i++)
    {
        for (int j=1; j<=sz; j++)
        {
            if (sta[i-1]==stb[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i][j-1], dp[i-1][j]);
        }
    }
    int i=sz, j=sz;
    while (i>0 && j>0)
    {
        if (sta[i-1]==stb[j-1]) ans=ans+sta[i-1], i--, j--;
        else if (dp[i][j-1]>=dp[i-1][j]) j--;
        else i--;
    }
    /*for (int i=1; i<=sz; i++)
    {
        for (int j=1; j<=sz; j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<'\n';
    }*/
    reverse(ans.begin(), ans.end());
    cout<<ans;
    cout<<'\n'<<dp[sz][sz]<<'\n';
    if (dp[sz][sz]>=sz/2) cout<<"y";
    else cout<<"n";
}