Submission #388181

#TimeUsernameProblemLanguageResultExecution timeMemory
388181Ahmadsm2005Counting Mushrooms (IOI20_mushrooms)C++14
80.43 / 100
12 ms312 KiB
#include<bits/stdc++.h> #include "mushrooms.h" using namespace std; ///Square ROOT 142 vector<int>REM; vector<int>A,B; int LAST,SQR=143; /*int use_machine(vector<int>F){ for(int i=0;i<F.size();i++) cout<<F[i]<<' '; int X; cin>>X; return X; }*/ int count_mushrooms(int n){ vector<int>m; A.push_back(0); m.push_back(0),m.push_back(1); if(use_machine(m)) B.push_back(1); else A.push_back(1); if(n==2){ return A.size(); } m.pop_back(),m.push_back(2); if(use_machine(m)) B.push_back(2); else A.push_back(2); LAST=3; for(int i=3;i<n;i+=2){ vector<int>TEMP; if(i+1==n){ TEMP.push_back(0),TEMP.push_back(i); if(use_machine(TEMP)) B.push_back(i); else A.push_back(i); return A.size(); } if(A.size()>=2){ TEMP.push_back(A[0]),TEMP.push_back(i),TEMP.push_back(A[1]),TEMP.push_back(i+1); int ANS=use_machine(TEMP); if(!ANS) A.push_back(i),A.push_back(i+1); else if(ANS==1) A.push_back(i),B.push_back(i+1); else if(ANS==2) A.push_back(i+1),B.push_back(i); else B.push_back(i),B.push_back(i+1); } else{ TEMP.push_back(B[0]),TEMP.push_back(i),TEMP.push_back(B[1]),TEMP.push_back(i+1); int ANS=use_machine(TEMP); if(!ANS) B.push_back(i),B.push_back(i+1); else if(ANS==1) B.push_back(i),A.push_back(i+1); else if(ANS==2) B.push_back(i+1),A.push_back(i); else A.push_back(i),A.push_back(i+1); } LAST=i+2; if(A.size()>=SQR||B.size()>=SQR){ break; } } bool SWAP=0; int AA=0; AA=A.size(); if(B.size()>=SQR) A=B,SWAP=1; for(int l=LAST;l<n;l+=SQR){ vector<int>LIST,TEMP; for(int x=l;x<min(n,l+SQR);x++){ LIST.push_back(x); } TEMP.push_back(A[0]); for(int i=0;i<LIST.size();i++){ TEMP.push_back(LIST[i]); if(i+1!=LIST.size()) TEMP.push_back(A[i+1]); } if(SWAP) AA+=(use_machine(TEMP)+1)/2; else AA+=(LIST.size()-(use_machine(TEMP)+1)/2); } return AA; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:67:12: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   67 | if(A.size()>=SQR||B.size()>=SQR){
      |    ~~~~~~~~^~~~~
mushrooms.cpp:67:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   67 | if(A.size()>=SQR||B.size()>=SQR){
      |                   ~~~~~~~~^~~~~
mushrooms.cpp:74:12: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   74 | if(B.size()>=SQR)
      |    ~~~~~~~~^~~~~
mushrooms.cpp:82:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 | for(int i=0;i<LIST.size();i++){
      |             ~^~~~~~~~~~~~
mushrooms.cpp:84:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 | if(i+1!=LIST.size())
      |    ~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...