Submission #303876

#TimeUsernameProblemLanguageResultExecution timeMemory
303876aintaCounting Mushrooms (IOI20_mushrooms)C++17
92.62 / 100
11 ms512 KiB
#include "mushrooms.h" #include<algorithm> using namespace std; int CK[200]; int count_mushrooms(int n) { int i, j; if(n<=200){ int res=1; for(i=1;i<n;i++){ vector<int>T={0,i}; res+=1-use_machine(T); } return res; } vector<int>Z[2]; Z[0].push_back(0); int ck, pv=0; for(i=1;;i++){ vector<int>T={0,i}; CK[i]=use_machine(T); Z[CK[i]].push_back(i); if(Z[CK[i]].size()==2){ ck=CK[i]; pv=i+1; break; } } for(i=pv;i<160;i+=2){ vector<int>T = {Z[ck][0],i,Z[ck][1],i+1}; int t = use_machine(T); if(t==0){ Z[ck].push_back(i); Z[ck].push_back(i+1); } if(t==1){ Z[ck].push_back(i); Z[!ck].push_back(i+1); } if(t==2){ Z[!ck].push_back(i); Z[ck].push_back(i+1); } if(t==3){ Z[!ck].push_back(i); Z[!ck].push_back(i+1); } pv=i+2; } int res=Z[0].size(); while(pv < n){ int cur, L; if(Z[0].size() < Z[1].size()){ cur = 1; } else{ cur = 0; } L = Z[cur].size(); vector<int>T; int s=0; for(i=pv;i<pv+L && i<n;i++){ s++; T.push_back(Z[cur][i-pv]); T.push_back(i); } int t = use_machine(T); if(cur==1) res += (t+1)/2; else res += s-(t+1)/2; if(pv+L>=n)break; if(t%2==1){ Z[!cur].push_back(pv+L-1); } else{ Z[cur].push_back(pv+L-1); } pv+=L; } return res; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:6:9: warning: unused variable 'j' [-Wunused-variable]
    6 |  int i, j;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...