Submission #1047496

#TimeUsernameProblemLanguageResultExecution timeMemory
1047496nightfalCounting Mushrooms (IOI20_mushrooms)C++17
63.66 / 100
6 ms596 KiB
#include <vector> #include <iostream> #include <tuple> using namespace std; int use_machine(std::vector<int> x); int count2(vector<int> &a, vector<int> &b, int &now, int n, int letter) { vector<int> m; int numA=0, numB=0; for(int i=0; i<a.size() && now < n; i++, now++) { m.push_back(a[i]); m.push_back(now); } int result = use_machine(m); if (result%2) numB++; else numA++; numB += result/2; numA += m.size()/2-1-result/2; if (letter) return numB; else return numA; } void count1(vector<int> &a, vector<int> &b, int num, int n) { int k = min(num,n); for(int i=3; i+1<k; i+=2) { int result = use_machine({a[0],i,a[1],i+1}); if (result%2) b.push_back(i+1); else a.push_back(i+1); if (result/2) b.push_back(i); else a.push_back(i); } if (k%2==0) { if(use_machine({a[0],k-1})) b.push_back(k-1); else a.push_back(k-1); } return; } int count_mushrooms(int n) { vector<int>a, b; a.push_back(0); int numA=0, number1=140; for(int i=1; i<min(3,n); i++) if (use_machine({0,i})) b.push_back(i); else a.push_back(i); if (n<=3) return a.size(); if(a.size()>=b.size()) count1(a,b,number1,n); else count1(b,a,number1,n); if (n<=number1) return a.size(); numA = a.size(); while (number1 < n) { if(a.size()>=b.size()) numA += count2(a,b,number1,n,0); else numA += count2(b,a,number1,n,1); } return numA; }

Compilation message (stderr)

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