#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cassert>
#include <map>
using namespace std;
#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(x) x.begin(), x.end()
#define uniq(x) x.erase(unique(all(x)), x.end())
#define index(x, y) (int)(lower_bound(all(x), y) - x.begin())
#define _1 first
#define _2 second
#define pb push_back
#define MOD 1000000007
const int B = 321;
string S;
int N;
map<int, int> C[300001];
signed main() {
cin >> S;
N = S.length();
assert(N <= 10000);
rep(l, N) {
int h = 0, rev = 0, p = 1;
for (int r=l; r<N; r++) {
h = (h*B+S[r])%MOD;
rev = (rev+1LL*p*S[r]) % MOD;
if (h == rev) C[r-l+1][h]++;
p = (1LL*p*B) % MOD;
}
}
long long m = 0;
for (int len=1; len<=N; len++) {
for (auto p : C[len]) {
m = max(m, 1LL*len*p._2);
}
}
cout << m << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
14328 KB |
Output is correct |
2 |
Correct |
12 ms |
14432 KB |
Output is correct |
3 |
Correct |
13 ms |
14504 KB |
Output is correct |
4 |
Correct |
12 ms |
14504 KB |
Output is correct |
5 |
Correct |
13 ms |
14504 KB |
Output is correct |
6 |
Correct |
12 ms |
14520 KB |
Output is correct |
7 |
Correct |
12 ms |
14576 KB |
Output is correct |
8 |
Correct |
12 ms |
14576 KB |
Output is correct |
9 |
Correct |
12 ms |
14612 KB |
Output is correct |
10 |
Correct |
12 ms |
14680 KB |
Output is correct |
11 |
Correct |
13 ms |
14680 KB |
Output is correct |
12 |
Correct |
13 ms |
14680 KB |
Output is correct |
13 |
Correct |
13 ms |
14680 KB |
Output is correct |
14 |
Correct |
13 ms |
14680 KB |
Output is correct |
15 |
Correct |
12 ms |
14680 KB |
Output is correct |
16 |
Correct |
14 ms |
14680 KB |
Output is correct |
17 |
Correct |
12 ms |
14680 KB |
Output is correct |
18 |
Correct |
15 ms |
14700 KB |
Output is correct |
19 |
Correct |
12 ms |
14700 KB |
Output is correct |
20 |
Correct |
12 ms |
14700 KB |
Output is correct |
21 |
Correct |
12 ms |
14700 KB |
Output is correct |
22 |
Correct |
12 ms |
14700 KB |
Output is correct |
23 |
Correct |
12 ms |
14700 KB |
Output is correct |
24 |
Correct |
12 ms |
14704 KB |
Output is correct |
25 |
Correct |
12 ms |
14704 KB |
Output is correct |
26 |
Correct |
12 ms |
14704 KB |
Output is correct |
27 |
Correct |
13 ms |
14704 KB |
Output is correct |
28 |
Correct |
12 ms |
14704 KB |
Output is correct |
29 |
Correct |
12 ms |
14704 KB |
Output is correct |
30 |
Correct |
13 ms |
14704 KB |
Output is correct |
31 |
Correct |
12 ms |
14704 KB |
Output is correct |
32 |
Correct |
12 ms |
14704 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
14704 KB |
Output is correct |
2 |
Correct |
17 ms |
14704 KB |
Output is correct |
3 |
Correct |
17 ms |
14704 KB |
Output is correct |
4 |
Correct |
20 ms |
14704 KB |
Output is correct |
5 |
Correct |
18 ms |
14760 KB |
Output is correct |
6 |
Correct |
17 ms |
14760 KB |
Output is correct |
7 |
Correct |
17 ms |
14760 KB |
Output is correct |
8 |
Correct |
18 ms |
14760 KB |
Output is correct |
9 |
Correct |
18 ms |
14760 KB |
Output is correct |
10 |
Correct |
17 ms |
14760 KB |
Output is correct |
11 |
Correct |
17 ms |
14760 KB |
Output is correct |
12 |
Correct |
19 ms |
14760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
636 ms |
15336 KB |
Output is correct |
2 |
Correct |
644 ms |
15340 KB |
Output is correct |
3 |
Correct |
497 ms |
15340 KB |
Output is correct |
4 |
Correct |
620 ms |
15340 KB |
Output is correct |
5 |
Correct |
448 ms |
15468 KB |
Output is correct |
6 |
Correct |
466 ms |
15468 KB |
Output is correct |
7 |
Correct |
508 ms |
15468 KB |
Output is correct |
8 |
Correct |
442 ms |
15468 KB |
Output is correct |
9 |
Correct |
453 ms |
15468 KB |
Output is correct |
10 |
Correct |
455 ms |
15468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
35 ms |
29524 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
36 ms |
29952 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |