# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
388045 | Supersonic | Counting Mushrooms (IOI20_mushrooms) | C++14 | 8 ms | 328 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;
int count_mushrooms(int n) {
int k=20001;
vector<int> a;vector<int> b;a.push_back(0);
int r1=use_machine({0,1});if(r1)b.push_back(1);else a.push_back(1);
if(n==2)return a.size();
int r2=use_machine({0,2});if(r2)b.push_back(2);else a.push_back(2);
if(n==3)return a.size();
int c=3;
if(a.size()==2){
while(c<n-1&&max(a.size(),b.size())<k){
r1=use_machine({a[0],c,a[1],c+1});
if(r1==0){a.push_back(c);a.push_back(c+1);}
if(r1==1){a.push_back(c);b.push_back(c+1);}
if(r1==2){b.push_back(c);a.push_back(c+1);}
if(r1==3){b.push_back(c);b.push_back(c+1);}
c+=2;
if(c>=10000)exit(1);
}
}
else{
while(c<n-1&&max(a.size(),b.size())<k){
r1=use_machine({b[0],c,b[1],c+1});
if(r1==0){b.push_back(c);b.push_back(c+1);}
if(r1==1){b.push_back(c);a.push_back(c+1);}
if(r1==2){a.push_back(c);b.push_back(c+1);}
if(r1==3){a.push_back(c);a.push_back(c+1);}
c+=2;
if(c>=10000)exit(1);
}
}
if(c==n-1){
if(use_machine({0,n-1})==1)b.push_back(n-1);
else a.push_back(n-1);
c++;
}
if(c==n)return a.size();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |