# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
289941 | 2020-09-03T08:50:48 Z | secretweapon | 회문 (APIO14_palindrome) | C++14 | 255 ms | 131076 KB |
#include <cstdio> #include <cstring> #include <map> #include <string> #include <iostream> #define N 600005 using namespace std; int P[N] = {0}; map <string,int> mp; string tmp= "", str, nw_str; int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); while(cin>>str) { memset(P,0,sizeof(P)); mp.clear(); // pre processing tmp = "$"; for(int i=0; i<str.size(); i++) { tmp += "#"; tmp += str[i]; } tmp += "#"; tmp += "@"; int c = 1; int r = 2; int n = tmp.size(); int mx = 1; int val; int idx, l, cnt; for(int i=2; i<n-1; i++) { idx = 2*c - i; P[i] = (i > r) ? 0 : ((P[idx]>(r-i)) ? r-i : P[idx]); while(tmp[i-P[i]]==tmp[i+P[i]]) { nw_str = tmp.substr(i-P[i],2*P[i]+1); cnt = mp[nw_str]++; //cout<<tmp.substr(i-l,l*2+1)<<endl; val = (cnt+1)*P[i]; mx = (mx < val) ? val : mx; P[i]++; } P[i]--; if((i+P[i])>r) { r = i + P[i]; c = i; } } cout<<mx<<endl; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2688 KB | Output is correct |
2 | Correct | 2 ms | 2688 KB | Output is correct |
3 | Correct | 2 ms | 2688 KB | Output is correct |
4 | Correct | 2 ms | 2688 KB | Output is correct |
5 | Correct | 2 ms | 2688 KB | Output is correct |
6 | Correct | 2 ms | 2688 KB | Output is correct |
7 | Correct | 2 ms | 2688 KB | Output is correct |
8 | Correct | 2 ms | 2688 KB | Output is correct |
9 | Correct | 2 ms | 2688 KB | Output is correct |
10 | Incorrect | 2 ms | 2688 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 4864 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 242 ms | 131076 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 249 ms | 131076 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 255 ms | 131076 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |