Submission

Status:

P---------

Subtask/Task Score:

10/100

Score: 10

User: KantaponZ

Problemset: Dvaravati-LCS

Language: cpp

Time: 0.033 second

Submitted On: 2025-11-08 22:52:42

#include <bits/stdc++.h>
using namespace std;

int dp[605][605];
string s[605][605];
string a, b;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> a >> b;
    int N = a.size();
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (a[i - 1] == b[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                s[i][j] = s[i - 1][j - 1] + a[i - 1];
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
                if (s[i - 1][j] > s[i][j - 1]) {
                    s[i][j] = s[i - 1][j];
                } else {
                    s[i][j] = s[i][j - 1];
                }
            }
            //cout << s[i][j] << "\t";
        }
        //cout << endl;
        
    }

    

    cout << s[N][N] << "\n" << dp[N][N] << "\n" << (dp[N][N] > N / 2 ? 'y' : 'n');
}