# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1047291 | nightfal | Counting Mushrooms (IOI20_mushrooms) | C++17 | 70 ms | 596 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 <vector>
#include <iostream>
#include <tuple>
using namespace std;
int use_machine(std::vector<int> x);
std::pair<int,int> count(int n, std::vector<int> &v) {
int numV=0, numW=0;
for(int i=3; i+1<n; i+=2) {
int result = use_machine({v[0],i,v[1],i+1});
if (result%2) numW++;
else numV++;
if (result/2) numW++;
else numV++;
}
if (n%2==0) {
if(use_machine({v[0],n-1})) numW++;
else numV++;
}
return {numV,numW};
}
int count_mushrooms(int n) {
vector<int> a, b; a.push_back(0);
int numA=0, numB=0;
for(int i=1; i<min(3,n); i++)
if (use_machine({0,i})) b.push_back(i);
else a.push_back(i);
if (n<=3) return a.size();
if (a.size()>=2) tie(numA,numB) = count(n,a);
else tie(numB,numA) = count(n,b);
numA += a.size(); numB += b.size();
return numA;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |