#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
string S;
bool dp[1005][1005];
map<string, int> mp;
void solve(){
ifstream in("input.txt");
ofstream out("output.txt");
cin>>S;
int N = S.length();
for(int i = 0; i < N; i++){
dp[i][i] = 1;
mp[S.substr(i, 1)]++;
}
for(int i = 0; i < N-1; i++){
if(S[i] == S[i+1]){
dp[i][i+1] = 1;
mp[S.substr(i, 2)]++;
}
}
for(int i = 3; i <= N; i++){
for(int j = 0; j <= N-i; j++){
int end = j+i-1;
if(dp[j+1][end-1] && S[j] == S[end]){
dp[j][end] = 1;
mp[S.substr(j, i)]++;
}
}
}
int ans = 0;
for(auto a : mp){
ans = max(ans, (int)(a.first.length())*a.second);
}
cout<<ans<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
79 ms |
1880 KB |
Output is correct |
2 |
Correct |
17 ms |
1616 KB |
Output is correct |
3 |
Correct |
109 ms |
1860 KB |
Output is correct |
4 |
Correct |
4 ms |
1364 KB |
Output is correct |
5 |
Correct |
117 ms |
1896 KB |
Output is correct |
6 |
Correct |
107 ms |
1872 KB |
Output is correct |
7 |
Correct |
2 ms |
1744 KB |
Output is correct |
8 |
Correct |
75 ms |
1832 KB |
Output is correct |
9 |
Correct |
5 ms |
1364 KB |
Output is correct |
10 |
Correct |
2 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1236 KB |
Output is correct |
12 |
Correct |
2 ms |
1624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
2516 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
3028 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
3708 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |