# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1052271 | fuad27 | Counting Mushrooms (IOI20_mushrooms) | C++17 | 70 ms | 1012 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) {
if(n == 2) {
return 2-use_machine({0, 1});
}
int bb = n;
int ss = use_machine({0, 1});
int tt = use_machine({0, 2});
vector<int> A, B;
A.push_back(0);
if(ss==0)
A.push_back(1);
else B.push_back(1);
if(tt==0)
A.push_back(2);
else B.push_back(2);
for(int i = 3;i<bb;i+=2) {
if(i + 1 < bb) {
if(A.size() >= 2) {
int val = use_machine(vector{A[0], i, A[1], i+1});
if(val < 2) {
A.push_back(i);
}
else B.push_back(i);
if(val%2 == 0) {
A.push_back(i+1);
}
else B.push_back(i+1);
}
else {
int val = use_machine(vector{B[0], i, B[1], i+1});
if(val < 2) {
B.push_back(i);
}
else A.push_back(i);
if(val%2 == 0) {
B.push_back(i+1);
}
else A.push_back(i+1);
}
}
else {
int val = use_machine(vector{A[0], i});
if(val==0) {
A.push_back(i);
}
else B.push_back(i);
}
}
return A.size();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |