Submission #600550

#TimeUsernameProblemLanguageResultExecution timeMemory
600550kig9981Counting Mushrooms (IOI20_mushrooms)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #ifdef NON_SUBMIT #define TEST(n) (n) #define tout cerr #else #define TEST(n) ((void)0) #define tout cin #endif using namespace std; vector<int> A, B, Q; void query1() { int a=Q.back(), b, r; Q.pop_back(); b=Q.back(); Q.pop_back(); if(A.size()>1) { r=use_machine({A[0],a,A[1],b}); if(r&1) B.push_back(b); else A.push_back(b); if(r>1) B.push_back(a); else A.push_back(a); } else { r=use_machine({B[0],a,B[1],b}); if(r&1) A.push_back(b); else B.push_back(b); if(r>1) A.push_back(a); else B.push_back(a); } } int query2() { int m=min(Q.size(),max(A.size(),B.size())), r; vector<int> I; if(A.size()>=m) { for(int i=0;i<m;i++) { I.push_back(A[i]); I.push_back(Q.back()); Q.pop_back(); } r=use_machine(I); if(r&1) B.push_back(I.back()); else A.push_back(I.back()); return m-1-(r>>1); } else { for(int i=0;i<m;i++) { I.push_back(B[i]); I.push_back(Q.back()); Q.pop_back(); } r=use_machine(I); if(r&1) A.push_back(I.back()); else B.push_back(I.back()); return r>>1; } } int count_mushrooms(int n) { int ret=0; bool rev=false; mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count()); if(n-1<=226) { ret=1; for(int i=1;i<n;i++) ret+=!use_machine({0,i}); return ret; } for(int i=1;i<n;i++) Q.push_back(i); shuffle(Q.begin(),Q.end(),mt); A.push_back(0); while(max(A.size(),B.size())<2, (Q.size()&1)) { int c=Q.back(); Q.pop_back(); if(use_machine({0,c})) B.push_back(c); else A.push_back(c); } for(int i=0;i<100;i++) { if(Q.empty()) break; query1(); } while(Q.size()) ret+=query2(); return ret+A.size(); }

Compilation message (stderr)

mushrooms.cpp: In function 'void query1()':
mushrooms.cpp:20:5: error: 'use_machine' was not declared in this scope
   20 |   r=use_machine({A[0],a,A[1],b});
      |     ^~~~~~~~~~~
mushrooms.cpp:27:5: error: 'use_machine' was not declared in this scope
   27 |   r=use_machine({B[0],a,B[1],b});
      |     ^~~~~~~~~~~
mushrooms.cpp: In function 'int query2()':
mushrooms.cpp:39:13: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |  if(A.size()>=m) {
      |     ~~~~~~~~^~~
mushrooms.cpp:44:5: error: 'use_machine' was not declared in this scope
   44 |   r=use_machine(I);
      |     ^~~~~~~~~~~
mushrooms.cpp:54:5: error: 'use_machine' was not declared in this scope
   54 |   r=use_machine(I);
      |     ^~~~~~~~~~~
mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:68:30: error: 'use_machine' was not declared in this scope
   68 |   for(int i=1;i<n;i++) ret+=!use_machine({0,i});
      |                              ^~~~~~~~~~~
mushrooms.cpp:74:30: warning: value computed is not used [-Wunused-value]
   74 |  while(max(A.size(),B.size())<2, (Q.size()&1)) {
      |        ~~~~~~~~~~~~~~~~~~~~~~^~
mushrooms.cpp:77:6: error: 'use_machine' was not declared in this scope
   77 |   if(use_machine({0,c})) B.push_back(c);
      |      ^~~~~~~~~~~
mushrooms.cpp:64:7: warning: unused variable 'rev' [-Wunused-variable]
   64 |  bool rev=false;
      |       ^~~