Submission #750305

#TimeUsernameProblemLanguageResultExecution timeMemory
750305mohav48173Counting Mushrooms (IOI20_mushrooms)C++14
46.03 / 100
14 ms336 KiB
#include "mushrooms.h" #include<bits/stdc++.h> using namespace std; const int cnt=100; int count_mushrooms(int n) { vector<int>a,b; a.push_back(0); for(int i=1;i<=min(n-1,cnt);i++) { if(use_machine({0,i})==0)a.push_back(i); else b.push_back(i); } int ans=a.size(); vector<int>cur; for(int i=cnt+1;i<n;i++) { cur.push_back(i); if(cur.size()>=max((int)a.size(),(int)b.size())) { vector<int>ask; bool flag=0; if(a.size()<b.size()){swap(a,b);flag=1;} for(int j=0;j<cur.size();j++) { ask.push_back(a[j]); ask.push_back(cur[j]); } int current=use_machine(ask); int nums=0; nums+=current%2; current-=current%2; nums+=current/2; if(!flag)nums=cur.size()-nums; ans+=nums; if(flag)swap(a,b); cur.clear(); } } if(cur.size()!=0) { vector<int>ask; bool flag=0; if(a.size()<b.size()){swap(a,b);flag=1;} for(int j=0;j<cur.size();j++) { ask.push_back(a[j]); ask.push_back(cur[j]); } int current=use_machine(ask); int nums=0; nums+=current%2; current-=current%2; nums+=current/2; if(!flag)nums=cur.size()-nums; ans+=nums; if(flag)swap(a,b); cur.clear(); } return ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:16:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   16 |         if(cur.size()>=max((int)a.size(),(int)b.size())) {
      |            ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mushrooms.cpp:20:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |             for(int j=0;j<cur.size();j++) {
      |                         ~^~~~~~~~~~~
mushrooms.cpp:39:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(int j=0;j<cur.size();j++) {
      |                         ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...