Submission #1054985

#TimeUsernameProblemLanguageResultExecution timeMemory
1054985LittleOrangeCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
0 ms344 KiB
#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 timeMemoryGrader output
Fetching results...