# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
959208 |
2024-04-07T17:07:24 Z |
Ariadna |
Savez (COCI15_savez) |
C++14 |
|
1000 ms |
31520 KB |
#include <bits/stdc++.h>
using namespace std;
vector<int> dp;
int solve(int i, int n, vector<string>& x) {
if (dp[i] != -1) return dp[i];
dp[i] = 1;
for (int j = i+1; j < n; ++j) {
if ((int)x[i].size() > (int)x[j].size()) continue;
bool prefix = true, suffix = true;
for (int k = 0; k < (int)x[i].size() && prefix; ++k) {
if (x[j][k] != x[i][k]) prefix = false;
}
if (!prefix) continue;
for (int k = 0; k < (int)x[i].size() && suffix; ++k) {
if (x[j][(int)x[j].size() - (int)x[i].size() + k] != x[i][k]) suffix = false;
}
if (!suffix) continue;
dp[i] = max(dp[i], 1 + solve(j, n, x));
}
return dp[i];
}
int main() {
int n;
cin >> n;
vector<string> x(n);
dp = vector<int>(n, -1);
for (int i = 0; i < n; ++i) cin >> x[i];
int ans = 0;
for (int i = 0; i < n; ++i) {
if (dp[i] == -1) ans = max(ans, solve(i, n, x));
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
302 ms |
3156 KB |
Output is correct |
2 |
Correct |
207 ms |
3084 KB |
Output is correct |
3 |
Correct |
283 ms |
3172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
600 KB |
Output is correct |
2 |
Correct |
200 ms |
2568 KB |
Output is correct |
3 |
Correct |
106 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1041 ms |
3216 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1040 ms |
3812 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1097 ms |
4432 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1048 ms |
5204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1037 ms |
19072 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1031 ms |
31520 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |