Submission #1052215

#TimeUsernameProblemLanguageResultExecution timeMemory
1052215noyancanturk버섯 세기 (IOI20_mushrooms)C++17
92.62 / 100
5 ms600 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; #define pb push_back int ind=1; vector<int>t1,t2; int count_mushrooms(int n) { t1.pb(0); while(ind<n&&t1.size()<2&&t2.size()<2){ int k=use_machine({0,ind}); if(k==1){ t2.pb(ind); }else{ t1.pb(ind); } ind++; } for(int i=0;i<75&&ind<n;i++){ if(ind==n-1){ int k=use_machine({0,ind}); if(k==1){ t2.pb(ind); }else{ t1.pb(ind); } ind++; }else if(1<t1.size()){ int k=use_machine({t1[0],ind,t1[1],ind+1}); if(!k){ t1.pb(ind); t1.pb(ind+1); }else if(k==1){ t1.pb(ind); t2.pb(ind+1); }else if(k==2){ t2.pb(ind); t1.pb(ind+1); }else{ t2.pb(ind); t2.pb(ind+1); } ind+=2; }else{ int k=use_machine({t2[0],ind,t2[1],ind+1}); if(!k){ t2.pb(ind); t2.pb(ind+1); }else if(k==1){ t2.pb(ind); t1.pb(ind+1); }else if(k==2){ t1.pb(ind); t2.pb(ind+1); }else{ t1.pb(ind); t1.pb(ind+1); } ind+=2; } } int ans=0; while(ind<n){ if(t2.size()<t1.size()){ vector<int>to; int j=ind; to.pb(t1[0]); for(int i=1;i<t1.size()&&j<n;i++){ to.pb(j++); to.pb(t1[i]); } if(j<n){ to.pb(j); int k=use_machine(to); ans+=(j-ind)-k/2; if(k&1)t2.pb(j); else t1.pb(j); j++; }else{ int k=use_machine(to); ans+=(j-ind)-k/2; } ind=j; }else{ vector<int>to; int j=ind; to.pb(t2[0]); for(int i=1;i<t2.size()&&j<n;i++){ to.pb(j++); to.pb(t2[i]); } if(j<n){ to.pb(j); int k=use_machine(to); ans+=k/2; if(k&1)t1.pb(j); else t2.pb(j); j++; }else{ int k=use_machine(to); ans+=k/2; } ind=j; } } return ans+t1.size(); }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:71:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |    for(int i=1;i<t1.size()&&j<n;i++){
      |                ~^~~~~~~~~~
mushrooms.cpp:91:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |    for(int i=1;i<t2.size()&&j<n;i++){
      |                ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...