Submission #211779

#TimeUsernameProblemLanguageResultExecution timeMemory
211779jzhJOIOJI (JOI14_joioji)C++14
95 / 100
73 ms11880 KiB
#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)

joioji.cpp: In function 'int main()':
joioji.cpp:7:12: warning: unused variable 'x' [-Wunused-variable]
     ll n,i,x,y,a=0,b=0,ans=0;
            ^
joioji.cpp:7:14: warning: unused variable 'y' [-Wunused-variable]
     ll n,i,x,y,a=0,b=0,ans=0;
              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...