제출 #423212

#제출 시각아이디문제언어결과실행 시간메모리
423212xyz버섯 세기 (IOI20_mushrooms)C++17
0 / 100
3 ms200 KiB
#include <bits/stdc++.h> #include "mushrooms.h" using namespace std; typedef long long ll; int m = 100; 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()); 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; } int x = use_machine(ask), y = ask.size(); if(pos + m < n){ 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; } int x = use_machine(ask), y = ask.size(); 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; }

컴파일 시 표준 에러 (stderr) 메시지

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:56:39: warning: unused variable 'y' [-Wunused-variable]
   56 |             int x = use_machine(ask), y = ask.size();
      |                                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...