Submission #367541

#TimeUsernameProblemLanguageResultExecution timeMemory
367541rumen_mCounting Mushrooms (IOI20_mushrooms)C++17
92.24 / 100
13 ms624 KiB
#include "mushrooms.h" # include <bits/stdc++.h> using namespace std; vector <int> l[2]; const int K = 93; int ans = 1; int count_mushrooms(int n) { int i,j; l[0].push_back(0); int x,y,type; vector <int> m; if(n==2) { m.push_back(0); m.push_back(1); int z = use_machine(m); return (z==0) ? 2 : 1; } for(i=1;i<=2;i++) { m.clear(); m.push_back(0); m.push_back(i); int z = use_machine(m); l[z].push_back(i); } if(l[0].size()>=2) { type = 0; x = l[0][0]; y = l[0][1]; } else { type = 1; x = l[1][0]; y = l[1][1]; } i = 3; // l[0].push_back(0); while(i+1<n&&l[0].size()<K&&l[1].size()<K) { m.clear(); m.push_back(i); i++; m.push_back(x); m.push_back(i); i++; m.push_back(y); int z = use_machine(m); l[(z&1)^type].push_back(i-2); l[((z&10)>>1)^type].push_back(i-1); } //cout<<"Here"<<endl; ans = l[0].size(); while(i<n) { m.clear(); type = l[0].size()<l[1].size(); for(j=0;j<l[type].size()&&i<n;j++) { m.push_back(i); i++; m.push_back(l[type][j]); } int z = use_machine(m); l[(z&1)^type].push_back(m[0]); z = z/2+z%2; if(type==1)ans+=z; else ans+=(i-m[0]-z); } return ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:62:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(j=0;j<l[type].size()&&i<n;j++)
      |                 ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...