Submission
Status:
P--P------
Score: 20
User: Cmoss9
Problemset: Dvaravati-LCS
Language: cpp
Time: 0.003 second
Submitted On: 2025-03-23 17:32:17
#include <bits/stdc++.h>
using namespace std;
int main () {
ios_base::sync_with_stdio(0); cin.tie(NULL);
string s1,s2;
cin >> s1 >> s2;
int length = s1.size();
int max_length = 0;
int start_index = 0;
vector<vector<int>> dp(length + 1, vector<int>(length + 1, 0));
for (int i = 1;i<=length;i++) {
for (int j = 1;j<=length;j++) {
if (s1[i - 1] == s2[j - 1]) {
dp[i][j] = dp[i - 1][j - 1] + 1;
if (dp[i][j] > max_length) {
max_length = dp[i][j];
start_index = i - max_length;
}
}
}
}
cout << s1.substr(start_index,max_length) << '\n';
cout << max_length << '\n';
if (max_length > length/2) {
cout << "y";
} else {
cout << "n";
}
}