제출 #623919

#제출 시각아이디문제언어결과실행 시간메모리
623919ollel버섯 세기 (IOI20_mushrooms)C++14
80.71 / 100
13 ms572 KiB
using namespace std; #include <bits/stdc++.h> #include "mushrooms.h" typedef vector<int> vi; typedef vector<vi> vvi; typedef long long ll; typedef vector<bool> vb; typedef pair<int,int> pii; #define rep(i,a,b) for(int i = a; i < b; i++) #define pb push_back set<int> A, B; int n; int nextQuery = 1; int ans = 1; void qa() { cerr << "a\n"; vi Q; for (auto a : A) { Q.pb(a); Q.pb(nextQuery); nextQuery++; if (nextQuery == n) break; } int x = use_machine(Q); int number_queried = Q.size() / 2; int bs = x/2 + (x&1); ans += number_queried - bs; cerr << number_queried << " " << number_queried - bs << endl; if (x & 1) B.insert(Q[Q.size() - 1]); else A.insert(Q[Q.size() - 1]); } void qb() { cerr << "b\n"; vi Q; for (auto a : B) { Q.pb(a); Q.pb(nextQuery); nextQuery++; if (nextQuery == n) break; } int x = use_machine(Q); int number_queried = Q.size() / 2; int as = x/2 + (x&1); ans += as; cerr << number_queried << " " << as << endl; if (x & 1) A.insert(Q[Q.size() - 1]); else B.insert(Q[Q.size() - 1]); } void make_query() { if (A.size() > B.size()) qa(); else qb(); } int count_mushrooms(int N) { n = N; A.insert(0); while (nextQuery != n) make_query(); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...