# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
388181 | Ahmadsm2005 | Counting Mushrooms (IOI20_mushrooms) | C++14 | 12 ms | 312 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<bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
///Square ROOT 142
vector<int>REM;
vector<int>A,B;
int LAST,SQR=143;
/*int use_machine(vector<int>F){
for(int i=0;i<F.size();i++)
cout<<F[i]<<' ';
int X;
cin>>X;
return X;
}*/
int count_mushrooms(int n){
vector<int>m;
A.push_back(0);
m.push_back(0),m.push_back(1);
if(use_machine(m))
B.push_back(1);
else
A.push_back(1);
if(n==2){
return A.size();
}
m.pop_back(),m.push_back(2);
if(use_machine(m))
B.push_back(2);
else
A.push_back(2);
LAST=3;
for(int i=3;i<n;i+=2){
vector<int>TEMP;
if(i+1==n){
TEMP.push_back(0),TEMP.push_back(i);
if(use_machine(TEMP))
B.push_back(i);
else
A.push_back(i);
return A.size();
}
if(A.size()>=2){
TEMP.push_back(A[0]),TEMP.push_back(i),TEMP.push_back(A[1]),TEMP.push_back(i+1);
int ANS=use_machine(TEMP);
if(!ANS)
A.push_back(i),A.push_back(i+1);
else if(ANS==1)
A.push_back(i),B.push_back(i+1);
else if(ANS==2)
A.push_back(i+1),B.push_back(i);
else
B.push_back(i),B.push_back(i+1);
}
else{
TEMP.push_back(B[0]),TEMP.push_back(i),TEMP.push_back(B[1]),TEMP.push_back(i+1);
int ANS=use_machine(TEMP);
if(!ANS)
B.push_back(i),B.push_back(i+1);
else if(ANS==1)
B.push_back(i),A.push_back(i+1);
else if(ANS==2)
B.push_back(i+1),A.push_back(i);
else
A.push_back(i),A.push_back(i+1);
}
LAST=i+2;
if(A.size()>=SQR||B.size()>=SQR){
break;
}
}
bool SWAP=0;
int AA=0;
AA=A.size();
if(B.size()>=SQR)
A=B,SWAP=1;
for(int l=LAST;l<n;l+=SQR){
vector<int>LIST,TEMP;
for(int x=l;x<min(n,l+SQR);x++){
LIST.push_back(x);
}
TEMP.push_back(A[0]);
for(int i=0;i<LIST.size();i++){
TEMP.push_back(LIST[i]);
if(i+1!=LIST.size())
TEMP.push_back(A[i+1]);
}
if(SWAP)
AA+=(use_machine(TEMP)+1)/2;
else
AA+=(LIST.size()-(use_machine(TEMP)+1)/2);
}
return AA;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |