Submission #436250

#TimeUsernameProblemLanguageResultExecution timeMemory
436250BelguteiCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
4 ms200 KiB
#include "mushrooms.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define mk make_pair int c; vector<int> v,v1; vector<int> tur; int count_mushrooms(int n) { if(n<=200){ c=1; for(int i=1; i<n; i++){ tur.clear(); tur.pb(0); tur.pb(i); c+=1-use_machine(tur); } return c; } // v.pb(0); tur.clear(); tur.pb(0); tur.pb(1); c=use_machine(tur); if(c==0) v.pb(1); else v1.pb(1); if(n==2) return v.size(); // if(v.size()==1){ tur.clear(); tur.pb(0); tur.pb(2); c=use_machine(tur); if(c==0) v.pb(2); else v1.pb(2); if(n==3) return v.size(); } // int ans=v.size(); if(v.size()==2){ for(int i=v.size()+v1.size()+1; i<200; i+=2){ tur.clear(); tur.pb(v[0]); tur.pb(i-1); tur.pb(v[1]); tur.pb(i); c=use_machine(tur); if(c==0){ v.pb(i); v.pb(i-1); } if(c==1){ v.pb(i); v1.pb(i-1); } if(c==2){ v.pb(i-1); v1.pb(i); } if(c==3){ v1.pb(i-1); v1.pb(i); } } } else{ for(int i=v.size()+v1.size()+1; i<200; i+=2){ tur.clear(); tur.pb(v[0]); tur.pb(i-1); tur.pb(v[1]); tur.pb(i); c=use_machine(tur); if(c==0){ v1.pb(i); v1.pb(i-1); } if(c==1){ v1.pb(i); v.pb(i-1); } if(c==2){ v1.pb(i-1); v.pb(i); } if(c==3){ v.pb(i-1); v.pb(i); } } } if(v.size()>v1.size()){ int i=v.size()+v1.size(); while(i<n){ tur.clear(); int pos=0; while(pos<v.size() && i<n){ tur.pb(v[pos]); tur.pb(i); i++; pos++; } int val=use_machine(tur); ans+=pos-(val+1)/2; } } else{ int i=v.size()+v1.size(); while(i<n){ tur.clear(); int pos=0; while(pos<v1.size() && i<n){ tur.pb(v1[pos]); tur.pb(i); i++; pos++; } int val=use_machine(tur); ans+=(val+1)/2; } } return ans; //int c2 = use_machine(m); }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:105:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |    while(pos<v.size() && i<n){
      |          ~~~^~~~~~~~~
mushrooms.cpp:120:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  120 |    while(pos<v1.size() && i<n){
      |          ~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...