# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
772395 | t6twotwo | Counting Mushrooms (IOI20_mushrooms) | C++17 | 1 ms | 208 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 A = use_machine({0, 1});
int B = use_machine({0, 2});
bool C = 0;
int ans;
if (A == 0) {
ans = 3 - B;
A = 0;
B = 1;
} else if (B == 0) {
ans = 2;
A = 0;
B = 2;
} else {
ans = N - 2;
A = 1;
B = 2;
C = 1;
}
for (int i = 3; i + 1 < N; i += 2) {
int x = use_machine({A, i, B, i + 1}), y;
if (x == 0) {
y = 2;
} else if (x == 3) {
y = 0;
} else {
y = 1;
}
ans += C ? -y : y;
}
if (N % 2 == 0) {
ans += 1 - use_machine({0, N - 1});
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |