# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
33982 | 2017-11-05T16:36:28 Z | mohammad_kilani | 회문 (APIO14_palindrome) | C++14 | 219 ms | 22620 KB |
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define oo 2000000000 const int N = 1010; int p = 1007; bool can[N][N]; unordered_map <long long,int> mp; char s[N]; int main() { //freopen("in.txt","r",stdin); scanf("%s",s); int n = strlen(s); long long ans = 0 ; for(int i=0;i<n;i++){ int idx = i; int idx2 = i; while(idx >= 0 && idx2 < n && s[idx] == s[idx2]){ can[idx][idx2] = true; idx--; idx2++; } idx = i; idx2 = i + 1; while(idx >= 0 && idx2 < n && s[idx] == s[idx2]){ can[idx][idx2] = true; idx--; idx2++; } } for(int i=0;i<n;i++){ long long tmp = 0 ; long long po = 1; for(int j=i;j<n;j++){ tmp+=(((long long)s[j] * po) % mod); tmp %= mod; po*= p; po%=mod; tmp %= mod; int cur = ++mp[tmp]; if(can[i][j] && ans < ((long long)cur * (j-i+1))){ ans = ((long long)cur * (j-i+1)); } } } cout << ans << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3016 KB | Output is correct |
2 | Correct | 0 ms | 3016 KB | Output is correct |
3 | Correct | 0 ms | 3016 KB | Output is correct |
4 | Correct | 0 ms | 3016 KB | Output is correct |
5 | Correct | 0 ms | 3016 KB | Output is correct |
6 | Correct | 0 ms | 3016 KB | Output is correct |
7 | Correct | 0 ms | 3016 KB | Output is correct |
8 | Correct | 0 ms | 3016 KB | Output is correct |
9 | Correct | 0 ms | 3016 KB | Output is correct |
10 | Correct | 0 ms | 3016 KB | Output is correct |
11 | Correct | 0 ms | 3016 KB | Output is correct |
12 | Correct | 0 ms | 3016 KB | Output is correct |
13 | Correct | 0 ms | 3016 KB | Output is correct |
14 | Correct | 0 ms | 3016 KB | Output is correct |
15 | Correct | 0 ms | 3016 KB | Output is correct |
16 | Correct | 0 ms | 3016 KB | Output is correct |
17 | Correct | 0 ms | 3016 KB | Output is correct |
18 | Correct | 0 ms | 3016 KB | Output is correct |
19 | Correct | 0 ms | 3016 KB | Output is correct |
20 | Correct | 0 ms | 3016 KB | Output is correct |
21 | Correct | 0 ms | 3148 KB | Output is correct |
22 | Correct | 0 ms | 3296 KB | Output is correct |
23 | Correct | 0 ms | 3016 KB | Output is correct |
24 | Correct | 0 ms | 3148 KB | Output is correct |
25 | Correct | 0 ms | 3016 KB | Output is correct |
26 | Correct | 0 ms | 3296 KB | Output is correct |
27 | Correct | 0 ms | 3148 KB | Output is correct |
28 | Correct | 0 ms | 3148 KB | Output is correct |
29 | Correct | 0 ms | 3296 KB | Output is correct |
30 | Correct | 0 ms | 3296 KB | Output is correct |
31 | Correct | 0 ms | 3296 KB | Output is correct |
32 | Correct | 0 ms | 3148 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 3148 KB | Output is correct |
2 | Correct | 123 ms | 17100 KB | Output is correct |
3 | Correct | 16 ms | 3016 KB | Output is correct |
4 | Correct | 196 ms | 21036 KB | Output is correct |
5 | Correct | 16 ms | 3016 KB | Output is correct |
6 | Correct | 13 ms | 3016 KB | Output is correct |
7 | Correct | 169 ms | 17604 KB | Output is correct |
8 | Correct | 13 ms | 3148 KB | Output is correct |
9 | Correct | 219 ms | 21564 KB | Output is correct |
10 | Correct | 219 ms | 22620 KB | Output is correct |
11 | Correct | 213 ms | 22620 KB | Output is correct |
12 | Correct | 209 ms | 18924 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 3016 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 0 ms | 3016 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 3016 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |