# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223276 | 2020-04-15T06:35:22 Z | errorgorn | Lampice (COCI19_lampice) | C++14 | 23 ms | 31616 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define ii pair<ll,ll> #define iii pair<ll,ii> #define endl '\n' int edges[300005][26]; int backedge[300005]; int len[300005]; int PREV=0; int INDEX=1; int n; string s; int main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>n>>s; int ans=0; memset(edges,-1,sizeof(edges)); backedge[0]=0,backedge[1]=0; len[0]=-1,len[1]=0; for (int x=0;x<s.size();x++){ while (s[x-len[PREV]-1]!=s[x]) PREV=backedge[PREV]; if (edges[PREV][s[x]-'a']==-1) edges[PREV][s[x]-'a']=++INDEX; int curr=edges[PREV][s[x]-'a']; len[curr]=len[PREV]+2; ans=max(ans,len[curr]); if (len[curr]==1){ backedge[curr]=1; } else{ int b=backedge[PREV]; while (s[x-len[b]-1]!=s[x]) b=backedge[b]; backedge[curr]=edges[b][s[x]-'a']; } PREV=curr; } cout<<ans<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 21 ms | 30848 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 30976 KB | Output is correct |
2 | Correct | 22 ms | 31360 KB | Output is correct |
3 | Correct | 21 ms | 31488 KB | Output is correct |
4 | Correct | 22 ms | 31488 KB | Output is correct |
5 | Correct | 22 ms | 31488 KB | Output is correct |
6 | Correct | 22 ms | 31616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 30976 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 21 ms | 30848 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |