# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211779 | jzh | JOIOJI (JOI14_joioji) | C++14 | 73 ms | 11880 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n,i,x,y,a=0,b=0,ans=0;
string s;
cin>>n>>s;
map<pair<ll,ll>,ll>mini,maxi;
s='.'+s;
for (i=1;i<=n;i++){
if (s[i]=='J')a++;
else if (s[i]=='O')a--;
if (s[i]=='O')b++;
else if (s[i]=='I')b--;
if (mini.find({a,b})==mini.end())mini[{a,b}]=i;
maxi[{a,b}]=i;
}
for (auto it:mini){
if (it.second!=maxi[it.first]){
ans=max(ans,maxi[it.first]-it.second);
}
}
cout<<ans<<'\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |