# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1054985 | LittleOrange | Counting Mushrooms (IOI20_mushrooms) | C++17 | 0 ms | 344 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;
using ll = int;
int count_mushrooms(int n) {
ll ans = 0;
ll cur = 1;
/*for(ll i = 1;i<n;i++){
cur^=use_machine({i-1,i});
ans += cur;
}*/
ll i = 0;
while(i+4<n){
ll g = use_machine({i,i+1,i+2,i+3,i+4});
ll cc = 0;
if (g==0){
cc = 4;
}else if (g==4){
cc = 2;
}else if (g==1){
ll g1 = use_machine({i+2,i+4,i+1,i+3,i+0});
if (g1==2) cc=4;
if (g1==4) cc=3;
if (g1==3) cc=2;
if (g1==1) cc=1;
}else if (g==2){
ll g1 = use_machine({i+1,i+0,i+2,i+4,i+3});
if (g1==4) cc=3;
if (g1==3) cc=2;
if (g1==2) cc=1;
}else{
ll g1 = use_machine({i+3,i+4,i+1,i+2});
if (g1>1) cc=3;
else cc=2;
}
ans += cc*cur+(4-cc)*(cur^1);
cur ^= g&1;
i+=4;
}
ans += cur;
while(i+1<n){
cur^=use_machine({i,i+1});
ans += cur;
i++;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |