# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
305919 | myungwoo | Counting Mushrooms (IOI20_mushrooms) | C++17 | 11 ms | 416 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;
int count_mushrooms(int N)
{
int K = 137;
vector<int> arr[2] = {{0}, {}};
int pt = 1;
// Step 1: Check type of mushroom one by one
while (pt < N){
arr[use_machine({0, pt})].push_back(pt);
pt++;
if (arr[0].size() >= 2 || arr[1].size() >= 2) break;
}
// Step 2: Check type of mushroom two by one
while (pt < N){
int t = arr[1].size() >= 2;
vector<int> test = {arr[t][0], pt, arr[t][1]};
if (pt+1 < N) test.push_back(pt+1);
int res = use_machine(test);
arr[res>>1&1^t].push_back(pt);
if (pt+1 < N) arr[res&1^t].push_back(pt+1);
pt += 2;
if (arr[0].size() >= K || arr[1].size() >= K) break;
}
// Step 3: Count number of type 0 mushrooms K by one
int zero_count = arr[0].size();
while (pt < N){
int t = arr[1].size() >= K;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |