Submission #303777

#TimeUsernameProblemLanguageResultExecution timeMemory
303777denkendoemeerCounting Mushrooms (IOI20_mushrooms)C++14
80.43 / 100
12 ms500 KiB
#include<bits/stdc++.h> #include "mushrooms.h" using namespace std; int count_mushrooms(int n) { vector<int>nr[2]; vector<int>aux; nr[0].push_back(0); int i,lim=140,ok,cnt=0,rez,ok2,ram,j; for(i=1;i<n && max(nr[0].size(),nr[1].size())<2;i++) nr[use_machine({0,i})].push_back(i); if (nr[1].size()==2) ok=1; else ok=0; for(;i<n && max(nr[0].size(),nr[1].size())<lim;i=i+2) { if (i+1<n) rez=use_machine({nr[ok][0],i,nr[ok][1],i+1}); else rez=use_machine({nr[ok][0],i,nr[ok][1]}); if (rez&2) ok2=1; else ok2=0; nr[ok^ok2].push_back(i); if (i+1<n) ok2=rez&1,nr[ok^ok2].push_back(i+1); } while(i<n) { if (nr[1].size()==max(nr[0].size(),nr[1].size())) ok=1; else ok=0; ram=min((int)max(nr[0].size(),nr[1].size()),n-i); aux.clear(); for(j=0;j<ram;j++) aux.push_back(nr[ok][j]),aux.push_back(i+j); rez=use_machine(aux); if (rez%2==1) rez++; if (ok) cnt=cnt+rez/2; else cnt=cnt+ram-rez/2; i+=ram; } return nr[0].size()+cnt; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:16:47: warning: comparison of integer expressions of different signedness: 'const long unsigned int' and 'int' [-Wsign-compare]
   16 |     for(;i<n && max(nr[0].size(),nr[1].size())<lim;i=i+2)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...