Submission #991866

#TimeUsernameProblemLanguageResultExecution timeMemory
991866tamir1Miners (IOI07_miners)C++17
45 / 100
1528 ms856 KiB
#include<bits/stdc++.h> using namespace std; int n,i,j,k,a1,a2,a3,b1,b2,b3,cnt,ans,x[100005]; string s; 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<(1<<(n-1));i++){ cnt=0; a1=0;a2=0;a3=0;b1=0;b2=0;b3=0; for(j=0;j<n;j++){ if(i&(1<<j)){ a3=a2; a2=a1; a1=x[j]; for(k=1;k<=3;k++){ if(a1==k || a2==k || a3==k) cnt++; } } else{ b3=b2; b2=b1; b1=x[j]; for(k=1;k<=3;k++){ if(b1==k || b2==k || b3==k) cnt++; } } } ans=max(ans,cnt); } 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...