# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223377 | 2020-04-15T08:22:58 Z | rainy | Lampice (COCI19_lampice) | C++17 | 22 ms | 1792 KB |
#include<bits/stdc++.h> #define MAXN 50005 #define pb push_back using namespace std; typedef vector<int> vi; int N,A,B; char c[MAXN]; map<char,vi> mp; int nx[MAXN]; int main(){ scanf("%d",&N); for(int i=0;i<N;i++){ scanf(" %c",&c[i]); mp[c[i]].pb(i); } for(int i=0;i<N;i++){ auto it=upper_bound(mp[c[i]].begin(), mp[c[i]].end(),i); if(it==mp[c[i]].end())nx[i]=-1; else nx[i]=*it; } for(int i=0;i<N-1;i++){ scanf("%d%d",&A,&B); assert(abs(A-B)==1); } int si=0; int ans=0; for(int j=1;j<N;j++){ if(nx[j]!=nx[j-1]-1){ if(nx[j-1]-(j-1)==1){ ans=max(ans, 2*(j-si)); } else if(nx[j-1]-(j-1)==2){ ans=max(ans, 2*(j-si)+1); } si=j; } } printf("%d\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 22 ms | 896 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 14 ms | 1792 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |