Submission #385174

#TimeUsernameProblemLanguageResultExecution timeMemory
385174Ahmadsm2005Counting Mushrooms (IOI20_mushrooms)C++14
0 / 100
140 ms384 KiB
#include<bits/stdc++.h> #include "mushrooms.h" using namespace std; ///Square ROOT 142 vector<int>REM; vector<int>A,B; int LAST,SQR=2; /*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(A.size()>=SQR+2||B.size()>=SQR+2){ LAST=i; break; } 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); } } bool SWAP=0; int AA=0; AA=A.size(); if(B.size()>=SQR+2) 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]); TEMP.push_back(A[i+1]); } if(SWAP) AA+=use_machine(TEMP)/2; else AA+=(LIST.size()-use_machine(TEMP)/2); } return AA; } /*int main(){ int n; cin>>n; cout<<count_mushrooms(n); }*/

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:34:12: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 | if(A.size()>=SQR+2||B.size()>=SQR+2){
      |    ~~~~~~~~^~~~~~~
mushrooms.cpp:34:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 | if(A.size()>=SQR+2||B.size()>=SQR+2){
      |                     ~~~~~~~~^~~~~~~
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+2)
      |    ~~~~~~~~^~~~~~~
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++){
      |             ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...