Submission #423220

#TimeUsernameProblemLanguageResultExecution timeMemory
423220xyzCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
1 ms200 KiB
#include <bits/stdc++.h> #include "mushrooms.h" using namespace std; typedef long long ll; int m = 2; int count_mushrooms(int n){ vector<int> A, B; A = {0}; int go = 2 * m + 5; for(int i = 1; i < min(n, go); i ++){ vector<int> ask = {0, i}; int x = use_machine(ask); if(!x) A.push_back(i); else B.push_back(i); } int result = A.size(), pos = go; while(pos < n){ m = max((int)A.size(), (int)B.size()) - 1; if(A.size() >= B.size()){ vector<int> ask; if(pos + m < n) ask.push_back(pos + m); ask.push_back(A[0]); int cur = 1; for(int j = pos; j < min(n, pos + m); j ++){ ask.push_back(j); ask.push_back(A[cur]); ++ cur; } // cout << "-query1" << endl; // cout << ask.size() << endl; // for(int e : ask) // cout << e << " "; // cout << endl; int x = use_machine(ask), y = ask.size(); if(pos + m < n){ -- y; if(x % 2 == 1){ B.push_back(pos + m); -- x; }else{ A.push_back(pos + m); } } result += ((y - 1) - x) / 2; pos += m + 1; }else{ vector<int> ask; if(pos + m < n) ask.push_back(pos + m); ask.push_back(B[0]); int cur = 1; for(int j = pos; j < min(n, pos + m); j ++){ ask.push_back(j); ask.push_back(B[cur]); ++ cur; } // cout << "-query2" << endl; int x = use_machine(ask); if(pos + m < n){ if(x % 2 == 1){ A.push_back(pos + m); -- x; }else{ B.push_back(pos + m); } } result += x / 2; pos += m + 1; } } return result; } //15 //0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
#Verdict Execution timeMemoryGrader output
Fetching results...