Submission #890926

#TimeUsernameProblemLanguageResultExecution timeMemory
890926Sir_Ahmed_ImranMiners (IOI07_miners)C++17
100 / 100
969 ms596 KiB
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define nl '\n' #define ff first #define ss second #define ll long long #define append push_back #define pii pair<int,int> #define all(x) (x).begin(),(x).end() set<int> x; inline int c(int& n,int& m,int& o){ if(n) x.insert(n); if(m) x.insert(m); if(o) x.insert(o); int z=x.size(); x.clear(); return z; } void solve(){ char s; int n,m,o,p,q,r; cin>>n; map<pair<pii,pii>,int> dp,dp2; dp[{{0,0},{0,0}}]=0; for(int i=0;i<n;i++){ cin>>s; if(s=='M') m=1; if(s=='F') m=2; if(s=='B') m=3; for(auto& i:dp){ o=i.ff.ff.ff; p=i.ff.ff.ss; q=i.ff.ss.ff; r=i.ff.ss.ss; dp2[{{p,m},{q,r}}]=max(dp2[{{p,m},{q,r}}] ,i.ss+c(o,p,m)); dp2[{{o,p},{r,m}}]=max(dp2[{{o,p},{r,m}}] ,i.ss+c(q,r,m)); } swap(dp,dp2); dp2.clear(); } o=0; for(auto& i:dp) o=max(o,i.ss); cout<<o; } int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); solve(); return 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...