Submission #388064

#TimeUsernameProblemLanguageResultExecution timeMemory
388064SupersonicCounting Mushrooms (IOI20_mushrooms)C++14
80.14 / 100
11 ms332 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; int count_mushrooms(int n) { int k=90; vector<int> a;vector<int> b;a.push_back(0); int r1=use_machine({0,1});if(r1)b.push_back(1);else a.push_back(1); if(n==2)return a.size(); int r2=use_machine({0,2});if(r2)b.push_back(2);else a.push_back(2); if(n==3)return a.size(); int c=3; if(a.size()>=2){ while(c<n-1&&max(a.size(),b.size())<k){ r1=use_machine({a[0],c,a[1],c+1}); if(r1==0){a.push_back(c);a.push_back(c+1);} if(r1==1){a.push_back(c);b.push_back(c+1);} if(r1==2){b.push_back(c);a.push_back(c+1);} if(r1==3){b.push_back(c);b.push_back(c+1);} c+=2; } } else{ while(c<n-1&&max(a.size(),b.size())<k){ r1=use_machine({b[0],c,b[1],c+1}); if(r1==0){b.push_back(c);b.push_back(c+1);} if(r1==1){b.push_back(c);a.push_back(c+1);} if(r1==2){a.push_back(c);b.push_back(c+1);} if(r1==3){a.push_back(c);a.push_back(c+1);} c+=2; } } if(c==n-1){ if(use_machine({0,n-1})==1)b.push_back(n-1); else a.push_back(n-1); c++; } if(c==n)return a.size(); int as=a.size(); while(c<n){ if(a.size()>b.size()){ vector<int> q;int t=0; for(auto i:a){q.push_back(i);t++;q.push_back(c);c++;if(c==n)break;} r1=use_machine(q); if(r1%2==1)b.push_back(q[q.size()-1]); r1++;r1/=2;as+=(t-r1); } else { vector<int> q; for(auto i:b){q.push_back(i);q.push_back(c);c++;if(c==n)break;} r1=use_machine(q); if(r1%2==1)a.push_back(q[q.size()-1]); r1++;r1/=2;as+=r1; } } return as; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:13:38: warning: comparison of integer expressions of different signedness: 'const long unsigned int' and 'int' [-Wsign-compare]
   13 |   while(c<n-1&&max(a.size(),b.size())<k){
      |                ~~~~~~~~~~~~~~~~~~~~~~^~
mushrooms.cpp:23:38: warning: comparison of integer expressions of different signedness: 'const long unsigned int' and 'int' [-Wsign-compare]
   23 |   while(c<n-1&&max(a.size(),b.size())<k){
      |                ~~~~~~~~~~~~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...