# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
432573 | saleh | Counting Mushrooms (IOI20_mushrooms) | C++17 | 121 ms | 512 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) {
vector<int> m = {0, 1}, nat;
for (int i = 0; i < n; i++) nat.push_back(0);
nat[0] = 1;
int c1 = use_machine(m);
if (c1 > 0) nat[1] = 2;
else nat[1] = 1;
if (n == 2) return 2 - c1;
m = {0, 2};
int c2 = use_machine(m);
if (c2 > 0) nat[2] = 2;
else nat[2] = 1;
int tmp = -1, pmt = -1;
if (c1 == 0) {
tmp = 0;
pmt = 1;
}
if (c2 == 0) {
tmp = 0;
pmt = 2;
}
if (c1 == c2 && c1 == 1) {
tmp = 1;
pmt = 2;
for (int i = 3; i + 1 < n; i += 2) {
m = {tmp, i, pmt, i + 1};
int chi = use_machine(m);
if (chi % 2 == 1) nat[i + 1] = 1;
else nat[i + 1] = 2;
if (chi >= 2) nat[i] = 1;
else nat[i] = 2;
}
if (n % 2 == 0) {
m = {tmp, n - 1};
if (use_machine(m) > 0) nat[n - 1] = 1;
else nat[n - 1] = 2;
}
} else {
for (int i = 3; i + 1 < n; i += 2) {
m = {tmp, i, pmt, i + 1};
int chi = use_machine(m);
if (chi % 2 == 1) nat[i + 1] = 2;
else nat[i + 1] = 1;
if (chi >= 2) nat[i] = 2;
else nat[i] = 1;
}
if (n % 2 == 0) {
m = {tmp, n - 1};
if (use_machine(m) > 0) nat[n - 1] = 2;
else nat[n - 1] = 1;
}
}
return count(nat.begin(), nat.end(), 1);
}
//int main() {}//
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |