# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
824026 | Abrar_Al_Samit | Counting Mushrooms (IOI20_mushrooms) | C++17 | 0 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 <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
int count_mushrooms(int n) {
vector<int>mac;
int c1 = use_machine(mac = {0, 1});
if(n==2) return 1 + 1-c1;
int c2 = use_machine(mac = {0, 2});
int tp[n];
tp[0] = 1;
tp[1] = 1-c1;
tp[2] = 1-c2;
int s1, s2;
if(c1 && c2) s1 = 1, s2 = 2;
else {
s1 = 0;
if(c1) s2 = 2;
else s2 = 1;
}
for(int i=3; i<n; i+=2) {
if(i==n-1) {
tp[i] = 1 - use_machine(mac = {0, i});
} else {
int c = use_machine(mac = {i, s1, i+1, s2});
if(c==0) {
tp[i] = tp[i+1] = tp[s1];
} else if(c==1) {
tp[i] = 1-tp[s1];
tp[i+1] = tp[s1];
} else {
tp[i+1] = 1-tp[s1];
tp[i] = tp[s1];
}
}
}
return accumulate(tp, tp+n, 0);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |