Submission #1080212

#TimeUsernameProblemLanguageResultExecution timeMemory
1080212Muhammad_AneeqCounting Mushrooms (IOI20_mushrooms)C++17
55.53 / 100
8 ms600 KiB
#include <vector> #include <iostream> using namespace std; int use_machine(vector<int> x); int count_mushrooms(int n) { vector<int>sz[2]={}; sz[0].push_back(0); int mx=80; for (int i=1;i<n;i++) { sz[use_machine({0,i})].push_back(i); if (sz[0].size()>=mx||sz[1].size()>=mx) break; } if (sz[1].size()>sz[0].size()) swap(sz[0],sz[1]); int cnt[2]={}; cnt[0]=sz[0].size(); for (int i=sz[0].size()+sz[1].size();i<n;i+=mx) { vector<int>qu; int f=min(i+mx,n)-i; for (int j=i;j<min(i+mx,n);j++) { qu.push_back(j); qu.push_back(sz[0][j-i]); } int x=use_machine(qu); cnt[0]+=f-(x+1)/2; } cnt[1]=n-cnt[0]; if (sz[0][0]==0) return cnt[0]; return cnt[1]; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:13:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |             if (sz[0].size()>=mx||sz[1].size()>=mx)
      |                 ~~~~~~~~~~~~^~~~
mushrooms.cpp:13:47: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |             if (sz[0].size()>=mx||sz[1].size()>=mx)
      |                                   ~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...