제출 #824877

#제출 시각아이디문제언어결과실행 시간메모리
824877NothingXD버섯 세기 (IOI20_mushrooms)C++17
0 / 100
1 ms208 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; void debug_out(){cerr << endl;} template<typename Head, typename... Tail> void debug_out(Head H, Tail... T){ cerr << H << ' '; debug_out(T...); } #define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__) #define F first #define S second #define all(x) x.begin(), x.end() #define MP(x, y) make_pair(x, y) const int maxn = 2e4 + 10; const int sq = 90; int count_mushrooms(int n) { vector<int> A, B; A.push_back(0); vector<int> ask = {0, 1}; if (use_machine(ask)){ B.push_back(1); } else{ A.push_back(1); } if (n == 2) return A.size(); ask = {0, 2}; if (use_machine(ask)){ B.push_back(2); } else{ A.push_back(2); } bool flg = false; if (A.size() == 1){ swap(A, B); flg = true; } for (int i = 3; i < n && A.size() < sq && B.size() < sq; i += 2){ vector<int> ask; ask.push_back(A[0]); ask.push_back(i); ask.push_back(A[1]); if (i+1 < n) ask.push_back(i+1); int tmp = use_machine(ask); if ((tmp >> 1) & 1) B.push_back(i); else A.push_back(i); if (tmp & 1) B.push_back(i+1); else if (i + 1 < n) A.push_back(i+1); } int sz; int cnta = 0, cntb = 0; for (int i = A.size()+B.size(); i < n; i += sz){ if (A.size() < B.size()){ swap(A, B); swap(cnta, cntb); flg = !flg; } sz = A.size(); //assert(0); vector<int> ask; for (int j = 0; j < A.size(); j++){ ask.push_back(A[j]); if (i+j < n) ask.push_back(i+j); } int tmp = use_machine(ask); if (i + sz-1 < n && tmp % 2 == 0) A.push_back(ask.back()); else if (i + sz-1 < n){ B.push_back(ask.back()); } cntb += (tmp+1)/2; cnta += min(sz, n-i) - (tmp+1)/2; } return (flg? B.size() + cntb: A.size() + cnta); }

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

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:72:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |   for (int j = 0; j < A.size(); j++){
      |                   ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...