Submission #1048235

#TimeUsernameProblemLanguageResultExecution timeMemory
1048235tamir1Miners (IOI07_miners)C++17
45 / 100
1602 ms13660 KiB
#include<bits/stdc++.h> using namespace std; int n,a[100010],i; string s; int val(vector<int> v){ set<int> s; for(int x:v){ if(x) s.insert(x); } return s.size(); } int rec(int idx,int a1,int a2,int b1,int b2){ if(idx==n) return 0; int m1,m2; m1=val({a1,a2,a[idx]}); m2=val({b1,b2,a[idx]}); return max(rec(idx+1,a[idx],a1,b1,b2)+m1,rec(idx+1,a1,a2,a[idx],b1)+m2); } int main(){ cin >> n >> s; for(i=0;i<n;i++){ if(s[i]=='M') a[i]=1; if(s[i]=='B') a[i]=2; if(s[i]=='F') a[i]=3; } cout << rec(0,0,0,0,0); }
#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...