| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 785949 | MilosMilutinovic | Rima (COCI17_rima) | C++14 | 1093 ms | 18016 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.
/**
* author: wxhtzdy
* created: 17.07.2023 22:01:28
**/
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<string> s(n);
for (int i = 0; i < n; i++) {
cin >> s[i];
}
auto Check = [&](string s, string t) {
int ptr = 0;
int si = (int) s.size();
int sj = (int) t.size();
while (ptr < min(si, sj) && s[si - ptr - 1] == t[sj - ptr - 1]) {
ptr += 1;
}
return (ptr >= max(si, sj) - 1);
};
vector<int> dp(n);
for (int i = 0; i < n; i++) {
dp[i] = 1;
for (int j = 0; j < i; j++) {
if (Check(s[i], s[j])) {
dp[i] = max(dp[i], dp[j] + 1);
}
}
}
cout << *max_element(dp.begin(), dp.end()) << '\n';
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
