# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
104483 | 2019-04-07T06:21:31 Z | E869120 | Palindromes (APIO14_palindrome) | C++14 | 967 ms | 1996 KB |
#include <iostream> #include <string> #include <map> #include <algorithm> #include <vector> using namespace std; long long L[10009]; string S; pair<long long, int> L1[10009]; int cnt1, cnt2; bool ispalindrome(string V) { for (int i = 0; i < V.size(); i++) { if (V[i] != V[V.size() - 1 - i]) return false; } return true; } int main() { cin >> S; for (int i = 0; i < S.size(); i++) L[i] = (S[i] - 'a') + 1; long long maxn = 0; // 真ん中が決まっている場合 cnt1 = 0; for (int t = 1; t <= 26; t++) { for (int i = 0; i < S.size(); i++) { if (L[i] == t) { L1[cnt1] = make_pair(L[i], i); cnt1++; } } } for (int i = 1; i <= S.size(); i += 2) { int t1 = 0; for (int j = 0; j < cnt1; j++) { t1++; maxn = max(maxn, 1LL * t1 * i); if (L1[j].first != L1[j + 1].first) t1 = 0; } vector<pair<long long, int>>G[28]; for (int j = 0; j < cnt1; j++) { int pos1 = L1[j].second - (i / 2) - 1, pos2 = L1[j].second + (i / 2) + 1; if (pos1 >= 0 && pos2 < S.size() && L[pos1] == L[pos2]) G[L[pos1]].push_back(make_pair(311LL * L1[j].first + L[pos1], L1[j].second)); } cnt1 = 0; for (int j = 1; j <= 26; j++) { for (int k = 0; k < G[j].size(); k++) { L1[cnt1] = G[j][k]; cnt1++; } } } // 真ん中が決まっていない場合 cnt1 = 0; for (int t = 1; t <= 26; t++) { for (int i = 0; i < S.size() - 1; i++) { if (L[i] == L[i + 1] && L[i] == t) { L1[cnt1] = make_pair(L[i], i); cnt1++; } } } for (int i = 2; i <= S.size(); i += 2) { int t1 = 0; for (int j = 0; j < cnt1; j++) { t1++; maxn = max(maxn, 1LL * t1 * i); if (L1[j].first != L1[j + 1].first) t1 = 0; } vector<pair<long long, int>>G[28]; for (int j = 0; j < cnt1; j++) { int pos1 = L1[j].second - (i / 2), pos2 = L1[j].second + (i / 2) + 1; if (pos1 >= 0 && pos2 < S.size() && L[pos1] == L[pos2]) G[L[pos1]].push_back(make_pair(311LL * L1[j].first + L[pos1], L1[j].second)); } cnt1 = 0; for (int j = 1; j <= 26; j++) { for (int k = 0; k < G[j].size(); k++) { L1[cnt1] = G[j][k]; cnt1++; } } } cout << maxn << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 3 ms | 256 KB | Output is correct |
6 | Correct | 3 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 412 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 356 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 2 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 256 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 256 KB | Output is correct |
24 | Correct | 3 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 2 ms | 256 KB | Output is correct |
27 | Correct | 2 ms | 256 KB | Output is correct |
28 | Correct | 2 ms | 256 KB | Output is correct |
29 | Correct | 3 ms | 512 KB | Output is correct |
30 | Correct | 2 ms | 384 KB | Output is correct |
31 | Correct | 2 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 11 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 13 ms | 384 KB | Output is correct |
6 | Correct | 10 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 7 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 505 ms | 1036 KB | Output is correct |
2 | Correct | 282 ms | 1996 KB | Output is correct |
3 | Correct | 967 ms | 1244 KB | Output is correct |
4 | Correct | 612 ms | 1128 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 22 ms | 768 KB | Output is correct |
7 | Correct | 89 ms | 808 KB | Output is correct |
8 | Correct | 4 ms | 512 KB | Output is correct |
9 | Correct | 5 ms | 512 KB | Output is correct |
10 | Incorrect | 7 ms | 640 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 1152 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 19 ms | 1436 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |