| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1090593 | onlk97 | Counting Mushrooms (IOI20_mushrooms) | C++14 | 1 ms | 344 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
const int Q=2;
int count_mushrooms(int n){
    if (n<=Q+1){
        vector <int> v(n);
        v[0]=0;
        for (int i=1; i<n; i++){
            int tp=use_machine({i-1,i});
            if (tp) v[i]=v[i-1]^1;
            else v[i]=v[i-1];
        }
        return count(v.begin(),v.end(),0);
    }
    vector <int> v(Q+1);
    v[0]=0;
    for (int i=1; i<=Q; i++){
        int tp=use_machine({i-1,i});
        if (tp) v[i]=v[i-1]^1;
        else v[i]=v[i-1];
    }
    int cnt0=count(v.begin(),v.end(),0),cnt1=count(v.begin(),v.end(),1);
    int ans=cnt0;
    cout<<cnt0<<' '<<cnt1<<'\n';
    if (cnt0>=cnt1){
        vector <int> pos;
        for (int i=0; i<=Q; i++) if (!v[i]) pos.push_back(i);
        for (int i=Q+1; i<n; i+=pos.size()){
            vector <int> ths;
            for (int j=i; j<min(n,i+(int)pos.size()); j++) ths.push_back(j);
            vector <int> ask;
            for (int j=0; j<ths.size(); j++){
                ask.push_back(pos[j]);
                ask.push_back(ths[j]);
            }
            int ret=ask.size()-1-use_machine(ask);
            ans+=(ret+1)/2;
        }
    } else {
        vector <int> pos;
        for (int i=0; i<=Q; i++) if (v[i]) pos.push_back(i);
        for (int i=Q+1; i<n; i+=pos.size()){
            vector <int> ths;
            for (int j=i; j<min(n,i+(int)pos.size()); j++) ths.push_back(j);
            vector <int> ask;
            for (int j=0; j<ths.size(); j++){
                ask.push_back(pos[j]);
                ask.push_back(ths[j]);
            }
            int ret=ask.size()-1-use_machine(ask);
            ans+=(int)ths.size()-(ret+1)/2;
        }
    }
    return ans;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
