Submission #156031

#TimeUsernameProblemLanguageResultExecution timeMemory
156031HungAnhGoldIBO2020JOIOJI (JOI14_joioji)C++14
100 / 100
54 ms9220 KiB
#include<iostream> #include<map> #define sum sum1 using namespace std; const int N=2e5+2; int sum[N][5]; map<pair<int,int>,int> min1; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n,i,j,k,l,ans=0; string s; cin>>n>>s; min1[{0,0}]=0; for(i=0;i<n;i++){ for(j=1;j<=3;j++){ sum[1+i][j]=sum[i][j]; } if(s[i]=='J'){ sum[i+1][1]++; } if(s[i]=='O'){ sum[i+1][2]++; } if(s[i]=='I'){ sum[i+1][3]++; } if(min1[{sum1[i+1][1]-sum1[i+1][2],sum1[i+1][2]-sum[i+1][3]}]==0){ if(sum1[i+1][1]-sum1[i+1][2]==0&&sum1[i+1][2]-sum[i+1][3]==0){ } else{ min1[{sum1[i+1][1]-sum1[i+1][2],sum1[i+1][2]-sum[i+1][3]}]=i+1; } } ans=max(ans,i+1-min1[{sum1[i+1][1]-sum1[i+1][2],sum1[i+1][2]-sum[i+1][3]}]); } cout<<ans; }

Compilation message (stderr)

joioji.cpp: In function 'int main()':
joioji.cpp:11:12: warning: unused variable 'k' [-Wunused-variable]
  int n,i,j,k,l,ans=0;
            ^
joioji.cpp:11:14: warning: unused variable 'l' [-Wunused-variable]
  int n,i,j,k,l,ans=0;
              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...