| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1302749 | sano | 버섯 세기 (IOI20_mushrooms) | C++20 | 0 ms | 0 KiB |
#include "mushrooms.h"
#include <set>
#define vec vector
#define For(i, n) for(int i = 0; i < n; i++)
using namespace std;
int count_mushrooms(int n) {
vec<int> odp(n, 0);
vec<int> m;
m.push_back(0);
vec<int> p(2, 0);
vec<int> m;
p[0]++;
m.push_back(0);
m.push_back(1);
int x = use_machine(m);
odp[1] = x;
p[odp[1]]++;
m.clear();
m.push_back(1);
m.push_back(2);
x = use_machine(m);
if(x == 1) odp[2] = 1 - odp[1];
else odp[2] = odp[1];
p[odp[2]]++;
int typ = 0;
if(p[1] >= 2){
typ = 1;
}
m.clear();
For(i, 3){
if(odp[i] == typ && m.size() < 2) m.push_back(i);
}
for (int i = 3; i < n; i+=2) {
vec<int> nm;
nm.push_back(m[0]);
nm.push_back(i);
nm.push_back(m[1]);
nm.push_back(i+1);
x = use_machine(nm);
if((x % 2) == 1){
odp[i+1] = 1 - typ;
}
else{
odp[i+1] = typ;
}
if(x > 1){
odp[i] = 1 - typ;
}
else{
odp[i] = typ;
}
}
For(i, n){
p[odp[i]]++;
}
return p[0];
}
