# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
884579 | jamjanek | Counting Mushrooms (IOI20_mushrooms) | C++14 | 7 ms | 988 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;
const int stala = 1;
int maska[3] = {0,0,1,};
vector<int>zapytanie[3] = {{0,1,},{},{},};
vector<int>graf[3] = {{1,2,},{},{},};
vector<int>A[2];
int Ac[2];
int it;
int count_mushrooms1(int n){
while(it<n){
// printf("it = %d\n", it);
vector<int>pom;
bool czy = 0;
if(A[1].size()>A[0].size())czy = 1;
int pom1 = 0;
while(it<n && pom.size()<2*A[czy].size()){
pom.push_back(A[czy][pom1++]);
pom.push_back(it);
it++;
}
int ans = use_machine(pom);
// printf("vec: = ");for(auto j: pom)printf("%d ", j);printf("\n");
// printf("ans = %d\n", ans);
if(ans%2==0)
A[czy].push_back(it-1);
else
A[!czy].push_back(it-1);
Ac[!czy]+=(ans+1)/2;
Ac[czy]+=pom1-(ans+1)/2;
if(pom1==2){
if(ans<2)
A[czy].push_back(it-2);
else
A[!czy].push_back(it-2);
}
}
// printf("res = %d\n", Ac[0]);
return Ac[0];
}
int count_mushrooms(int n){
A[0].push_back(0);
it = 1;
Ac[0] = 1;
Ac[1] = 0;
if(n<=stala+1)
return count_mushrooms1(n);
int x = 0;
while(graf[x].size()>0){
int c = use_machine(zapytanie[x]);
x = graf[x][c];
}
x = maska[x];
for(int i=0;i<stala;i++){
if((x>>i)&1){
A[1].push_back(i+1);
Ac[1]++;
}
else{
A[0].push_back(i+1);
Ac[0]++;
}
}
it = stala+1;
return count_mushrooms1(n);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |