# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
48018 | 2018-05-09T11:53:10 Z | E869120 | Palindromes (APIO14_palindrome) | C++14 | 1000 ms | 11788 KB |
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; string S; int L[100009], N, col[100009], cnts; vector<int>x[100009], y[100009]; long long Get(int pos) { if (pos < 0) return -1; if (pos >= N) return -2; return L[pos]; } int main() { cin >> S; N = S.size(); for (int i = 0; i < N; i++) L[i] = (S[i] - 'a'); for (int i = 0; i < N; i++) x[0].push_back(i); long long maxn = 0; cnts = 1; for (int i = 0; i <= N / 2 + 1; i++) { int cnt = 0; for (int j = 0; j < cnts; j++) { if (x[j].size() == 1) { int to = x[j][0]; if (Get(to - i) == Get(to + i)) { y[cnt] = x[j]; cnt++; } continue; } vector<int>H[26]; for (int k = 0; k < x[j].size(); k++) { int to = x[j][k]; if (Get(to - i) != Get(to + i)) continue; H[Get(to + i)].emplace_back(to); } for (int k = 0; k < 26; k++) { if (H[k].size() >= 1) { y[cnt] = H[k]; cnt++; } } } for (int j = 0; j < cnt; j++) { x[j] = y[j]; maxn = max(maxn, 1LL * (long long)x[j].size()*(i * 2 + 1)); } cnts = cnt; } for (int i = 0; i < 100009; i++) x[i].clear(); cnts = 1; for (int i = 0; i < N; i++) x[0].push_back(i); for (int i = 0; i <= N / 2 + 1; i++) { int cnt = 0; for (int j = 0; j < cnts; j++) { if (x[j].size() == 1) { int to = x[j][0]; if (Get(to - i) == Get(to + i)) { y[cnt] = x[j]; cnt++; } continue; } vector<int>H[26]; for (int k = 0; k < x[j].size(); k++) { int to = x[j][k]; if (Get(to - i) != Get(to + i + 1)) continue; H[Get(to + i)].emplace_back(to); } for (int k = 0; k < 26; k++) { if (H[k].size() >= 1) { y[cnt] = H[k]; cnt++; } } } for (int j = 0; j < cnt; j++) { x[j] = y[j]; maxn = max(maxn, 1LL * (long long)x[j].size()*(i * 2 + 2)); } cnts = cnt; } cout << maxn << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4984 KB | Output is correct |
2 | Correct | 6 ms | 5096 KB | Output is correct |
3 | Correct | 5 ms | 5164 KB | Output is correct |
4 | Incorrect | 5 ms | 5164 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 5248 KB | Output is correct |
2 | Correct | 7 ms | 5296 KB | Output is correct |
3 | Correct | 10 ms | 5296 KB | Output is correct |
4 | Correct | 6 ms | 5296 KB | Output is correct |
5 | Correct | 10 ms | 5296 KB | Output is correct |
6 | Correct | 11 ms | 5296 KB | Output is correct |
7 | Correct | 6 ms | 5296 KB | Output is correct |
8 | Correct | 8 ms | 5296 KB | Output is correct |
9 | Correct | 6 ms | 5296 KB | Output is correct |
10 | Correct | 5 ms | 5296 KB | Output is correct |
11 | Correct | 5 ms | 5296 KB | Output is correct |
12 | Incorrect | 6 ms | 5296 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 169 ms | 5580 KB | Output is correct |
2 | Correct | 100 ms | 5580 KB | Output is correct |
3 | Correct | 363 ms | 5580 KB | Output is correct |
4 | Correct | 269 ms | 5580 KB | Output is correct |
5 | Correct | 8 ms | 5604 KB | Output is correct |
6 | Correct | 17 ms | 5604 KB | Output is correct |
7 | Correct | 47 ms | 5604 KB | Output is correct |
8 | Correct | 6 ms | 5604 KB | Output is correct |
9 | Correct | 6 ms | 5604 KB | Output is correct |
10 | Correct | 8 ms | 5604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1076 ms | 7396 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 21 ms | 11788 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |