Submission
Status:
P--P---P--
Subtask/Task Score:
30/100
Score: 30
User: theem1502
Problemset: Dvaravati-LCS
Language: cpp
Time: 0.080 second
Submitted On: 2026-02-24 23:54:11
#include <bits/stdc++.h>
using namespace std;
string first;
string second;
string cmp(string first, string second) {
if (first.length() >= second.length()) {
return first;
}
return second;
}
string recursion(int i, int j, vector<vector<string>> &dp) {
// cout << "debug " << i << " " << j << "\n";
if (i == -1 || j == -1) {
return "";
}
if (dp[i][j].length() == 0) {
return dp[i][j];
}
if (dp[i][j][0] != '1') {
return dp[i][j];
}
if (first[i] == second[j]) {
return dp[i][j] = cmp(cmp(recursion(i - 1, j-1, dp) + first[i], recursion(i -1 , j, dp)), recursion(i, j-1, dp));
}
else {
return dp[i][j] = cmp(recursion(i - 1, j, dp), recursion(i, j-1, dp));
}
}
int main() {
cin >> first >> second;
vector<vector<string>> dp(first.length(), vector<string> (second.length(), "1"));
string result = recursion(first.length()-1, second.length() - 1, dp);
cout << result;
int thenum = result.length();
cout << "\n" << thenum << "\n";
if (thenum < first.length() / 2) {
cout << 'n';
return 0;
}
cout<< 'y';
}