# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
690272 | moonhero | Round words (IZhO13_rowords) | C++17 | 11 ms | 11860 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e3 + 5;
int dp[N][N];
int main () {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
string a, b; cin >> a >> b;
sort(a.begin(), a.end());
sort(b.begin(), b.end());
for (int i = 0; i <= a.size(); i++) {
for (int j = 0; j <= b.size(); j++) {
dp[i][j] = 0;
}
} 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] = 1 + dp[i - 1][j - 1];
} dp[i][j] = max({dp[i][j - 1], dp[i - 1][j], dp[i][j]});
}
} cout << dp[a.size()][b.size()];
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |