Submission #991876

#TimeUsernameProblemLanguageResultExecution timeMemory
991876tamir1Miners (IOI07_miners)C++17
25 / 100
3 ms1112 KiB
#include<bits/stdc++.h> using namespace std; int n,i,j,ans,x[100005],p,q; string s; array<int,3> a,b; int give(int a,int b,int c){ int ans=0; if(a==1 || b==1 || c==1) ans++; if(a==2 || b==2 || c==2) ans++; if(a==3 || b==3 || c==3) ans++; return ans; } array<int,3> split(array<int,3> a,int val){ return {val,a[0],a[1]}; } int main(){ cin >> n >> s; for(i=0;i<n;i++){ if(s[i]=='M') x[i]=1; if(s[i]=='F') x[i]=2; if(s[i]=='B') x[i]=3; } for(i=0;i<n;i++){ if(a[0]==b[0] && a[1]==b[1]){ a=split(a,x[i]); ans+=give(a[0],a[1],a[2]); continue; } p=give(x[i],a[0],a[1]); q=give(x[i],b[0],b[1]); if(p>q){ a=split(a,x[i]); ans+=p; continue; } if(q>p){ b=split(b,x[i]); ans+=q; continue; } if(p==1){ ans++; if(a[0]==1 && b[0]==1){ if(a[1]==0) a=split(a,x[i]); else b=split(b,x[i]); } else{ if(a[0]==0) a=split(a,x[i]); else b=split(b,x[i]); } continue; } if(p==2){ ans+=2; if(a[0]==b[0] || a[1]==b[1]) a=split(a,x[i]); else{ if(a[0]==x[i]) b=split(b,x[i]); else a=split(a,x[i]); } continue; } ans+=3; a=split(a,x[i]); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...