Submission #156033

#TimeUsernameProblemLanguageResultExecution timeMemory
156033puppies_and_rainbowsJOIOJI (JOI14_joioji)C++14
100 / 100
93 ms7304 KiB
#include <bits/stdc++.h> #define int long long using namespace std; map<int, int> a; int n; string s; int hashed[200005]; int cj, co, ci; int lel(int x, int y, int z) { int ax=min(x, min(y,z)); x-=ax, y-=ax, z-=ax; return x*200000*200000+y*200000+z; } signed main() { cin>>n; cin>>s; for(int i=0; i<n; i++) { if(s[i]=='J') { cj++; } if(s[i]=='O') { co++; } if(s[i]=='I') { ci++; } hashed[i]=lel(ci,co,cj); a[hashed[i]]=1000000000; } for(int i=n-1; i>=0; i--) { a[hashed[i]]=min(a[hashed[i]], i); } a[0]=-1; int ans=0; for(int i=0; i<n; i++) { ans=max(ans, i-a[hashed[i]]); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...