Submission #530747

# Submission time Handle Problem Language Result Execution time Memory
530747 2022-02-26T16:15:07 Z perchuts Miners (IOI07_miners) C++17
25 / 100
19 ms 588 KB
#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 time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -