# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
265433 | 2020-08-14T20:35:01 Z | square1001 | Palindromes (APIO14_palindrome) | C++14 | 492 ms | 131076 KB |
#include <string> #include <vector> #include <iostream> #include <algorithm> using namespace std; bool is_palindrome(string str) { for(int i = 0; i < str.size(); ++i) { if(str[i] != str[str.size() - i - 1]) { return false; } } return true; } int main() { string S; cin >> S; int N = S.size(); vector<string> pals; for(int i = 0; i < N; ++i) { for(int j = i + 1; j <= N; ++j) { if(is_palindrome(S.substr(i, j - i))) { pals.push_back(S.substr(i, j - i)); } } } sort(pals.begin(), pals.end()); int cont = 1; long long ans = 0; for(int i = 1; i <= pals.size(); ++i) { if(i == pals.size() || pals[i - 1] != pals[i]) { ans = max(ans, 1LL * cont * int(pals[i - 1].size())); cont = 1; } else ++cont; } cout << ans << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 1 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 256 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 2 ms | 512 KB | Output is correct |
20 | Correct | 2 ms | 512 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 768 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 2 ms | 800 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 256 KB | Output is correct |
31 | Correct | 1 ms | 256 KB | Output is correct |
32 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 492 ms | 92624 KB | Output is correct |
2 | Correct | 151 ms | 24288 KB | Output is correct |
3 | Runtime error | 228 ms | 131076 KB | Execution killed with signal 9 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 176 ms | 131076 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 176 ms | 131072 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 196 ms | 131076 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |