Submission #602070

#TimeUsernameProblemLanguageResultExecution timeMemory
602070FatihSolakCounting Mushrooms (IOI20_mushrooms)C++17
92.62 / 100
9 ms336 KiB
#include "mushrooms.h" #include <bits/stdc++.h> #define N 20000 using namespace std; int count_mushrooms(int n){ vector<int> a,b; a.push_back(0); int point = 1; int cur = 0; while(cur < 85 && n-point > max(a.size(),b.size()) ){ if(max(a.size(),b.size()) == 1){ if(use_machine({0,point})){ b.push_back(point); } else a.push_back(point); point++; } else{ if(a.size() > b.size()){ vector<int> ask; ask.push_back(a[0]); ask.push_back(point++); ask.push_back(a[1]); ask.push_back(point++); int val = use_machine(ask); if(val < 2){ a.push_back(ask[1]); } else{ b.push_back(ask[1]); } if(val % 2 == 0){ a.push_back(ask[3]); } else{ b.push_back(ask[3]); } } else{ vector<int> ask; ask.push_back(b[0]); ask.push_back(point++); ask.push_back(b[1]); ask.push_back(point++); int val = use_machine(ask); if(val < 2){ b.push_back(ask[1]); } else{ a.push_back(ask[1]); } if(val % 2 == 0){ b.push_back(ask[3]); } else{ a.push_back(ask[3]); } } } cur++; } int ret = a.size(); while(point < n){ int asz = a.size(); int bsz = b.size(); if(asz > bsz){ vector<int> nums; int cnt = 0; for(int j = point;j<min(n,point + asz);j++){ nums.push_back(a[cnt++]); nums.push_back(j); } int sz = nums.size()/2; int val = use_machine(nums); point += asz; if(val&1){ b.push_back(point-1); } else a.push_back(point-1); ret += sz - (val + 1)/2; } else{ vector<int> nums; int cnt = 0; for(int j = point;j<min(n,point + bsz);j++){ nums.push_back(b[cnt++]); nums.push_back(j); } int sz = nums.size()/2; int val = use_machine(nums); point += bsz; if(val&1){ a.push_back(point-1); } else b.push_back(point-1); ret += (val + 1)/2; } } return ret; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:11:28: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   11 |  while(cur < 85 && n-point > max(a.size(),b.size()) ){
      |                    ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mushrooms.cpp:90:8: warning: unused variable 'sz' [-Wunused-variable]
   90 |    int sz = nums.size()/2;
      |        ^~
#Verdict Execution timeMemoryGrader output
Fetching results...