Submission #1047457

#TimeUsernameProblemLanguageResultExecution timeMemory
1047457nightfalCounting Mushrooms (IOI20_mushrooms)C++17
Compilation error
0 ms0 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 numA; else return numB; } void count1(vector<int> &a, vector<int> &b, int num) { 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=100; 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); else count1(b,a,number1); if (n<=100) return a.size(); while (number1 < n-1) { 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++) {
      |                  ~^~~~~~~~~
mushrooms.cpp: In function 'void count1(std::vector<int>&, std::vector<int>&, int)':
mushrooms.cpp:25:21: error: 'n' was not declared in this scope
   25 |     int k = min(num,n);
      |                     ^