답안 #113320

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
113320 2019-05-24T22:48:41 Z Runtime_error_ 회문 (APIO14_palindrome) C++14
23 / 100
281 ms 17524 KB
#include <bits/stdc++.h>
using namespace std;
const int inf=2e3+9;
int n,ans;
string s;
int pal[inf][inf];
map<string,int> mp;

int main(){

    cin>>s;
    n=s.size();
    s=" "+s;

    for(int i=1;i<=n;i++)
        pal[i][i]=1,pal[i][i+1]=(i<n && s[i]==s[i+1]);

    for(int len=3;len<=n;len++)
        for(int i=1;i<=n-len+1;i++)
            pal[i][i+len-1]=(pal[i+1][i+len-2] & s[i]==s[i+len-1]);

    for(int i=1;i<=n;i++){
        string temp="";
        for(int j=i;j<=n;j++){
            temp+=s[j];
            if(pal[i][j])
               mp[temp]++,ans=max(ans,mp[temp]*(j-i+1));
        }
    }
    cout<<ans<<endl;
}

Compilation message

palindrome.cpp: In function 'int main()':
palindrome.cpp:20:54: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
             pal[i][i+len-1]=(pal[i+1][i+len-2] & s[i]==s[i+len-1]);
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 2 ms 556 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 768 KB Output is correct
20 Correct 2 ms 768 KB Output is correct
21 Correct 2 ms 768 KB Output is correct
22 Correct 2 ms 768 KB Output is correct
23 Correct 3 ms 768 KB Output is correct
24 Correct 3 ms 768 KB Output is correct
25 Correct 4 ms 716 KB Output is correct
26 Correct 2 ms 768 KB Output is correct
27 Correct 7 ms 740 KB Output is correct
28 Correct 2 ms 768 KB Output is correct
29 Correct 2 ms 768 KB Output is correct
30 Correct 2 ms 768 KB Output is correct
31 Correct 2 ms 768 KB Output is correct
32 Correct 2 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 141 ms 6904 KB Output is correct
2 Correct 51 ms 6496 KB Output is correct
3 Correct 281 ms 6928 KB Output is correct
4 Correct 16 ms 6400 KB Output is correct
5 Correct 277 ms 6784 KB Output is correct
6 Correct 281 ms 6904 KB Output is correct
7 Correct 13 ms 6656 KB Output is correct
8 Correct 136 ms 6784 KB Output is correct
9 Correct 13 ms 6400 KB Output is correct
10 Correct 10 ms 6272 KB Output is correct
11 Correct 9 ms 6272 KB Output is correct
12 Correct 12 ms 6656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 31 ms 16640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 33 ms 16976 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 39 ms 17524 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -