# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1119459 | Tsagana | Round words (IZhO13_rowords) | C++14 | 63 ms | 63172 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>
#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
using namespace std;
string s, t;
int n, m, k;
int R[2001][4001];
int L[2001][4001];
int calc() {
int ans = 0;
memset(R, 0, sizeof R);
memset(L, 0, sizeof L);
for (int i = 1; i <= m; i++) R[0][i] = i;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
if (s[i] == t[j]) {
R[i][j] = L[i][j-1];
L[i][j] = R[i-1][j];
}
else {
R[i][j] = max(L[i][j-1], R[i-1][j]);
L[i][j] = min(L[i][j-1], R[i-1][j]);
}
}
for (int i = 1; i <= k; i++) {
int cnt = 0;
for (int j = i; j <= i+k-1; j++) if (R[n][j] <= i-1) cnt++;
ans = max(ans, cnt);
}
return ans;
}
void solve () {
cin >> s >> t;
n = s.size();
k = t.size();
m = 2 * k;
s = " " + s;
t = " " + t + t;
int ans = calc();
reverse(t.begin()+1, t.begin()+m+1);
ans = max(ans, calc());
cout << ans;
}
int main() {IOS solve(); return 0;}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |