Submission #530747

#TimeUsernameProblemLanguageResultExecution timeMemory
530747perchutsMiners (IOI07_miners)C++17
25 / 100
19 ms588 KiB
#include <bits/stdc++.h> #define maxn (int)(1e5+51) #define all(x) x.begin(), x.end() #define sz(x) (int) x.size() #define endl '\n' #define ll long long #define pb push_back #define ull unsigned long long #define ii pair<int,int> #define iii tuple<int,int,int> #define inf 2000000001 #define mod 1000000007 //998244353 #define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; } template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; } void printvector(vector<char>v){ for(auto x:v)cout<<x<<" "; cout<<endl; } vector<char>a,b; int x[3]={'M','F','B'}; int main(){_ int n;cin>>n; string s;cin>>s; int ans = 0; for(int i=0;i<n;++i){ int p1=0,p2=0, j=max(sz(a)-2,0); // cout<<"a "; // printvector(a); // cout<<"b "; // printvector(b); vector<char>tmp1,tmp2; while(j<sz(a))tmp1.pb(a[j++]); tmp1.pb(s[i]); for(int k=0;k<3;++k){ int ok = 0; for(auto l:tmp1)ok|=(l==x[k]); p1+=ok; } j=max(sz(b)-2,0); while(j<sz(b))tmp2.pb(b[j++]); tmp2.pb(s[i]); for(int k=0;k<3;++k){ int ok = 0; for(auto l:tmp2)ok|=(l==x[k]); p2+=ok; } if(p1>p2){ a = tmp1; ans+=p1; }else if(p1==p2){ if(sz(tmp1)<=sz(tmp2)){ a = tmp1, ans += p1; }else if(sz(tmp1)>sz(tmp2)){ b = tmp2, ans += p2; } }else{ b = tmp2; ans+=p2; } } cout<<ans<<endl; }
#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...