제출 #623918

#제출 시각아이디문제언어결과실행 시간메모리
623918ollel버섯 세기 (IOI20_mushrooms)C++14
0 / 100
1 ms208 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() { 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 = number_queried - x/2 + (x&1); ans += number_queried - bs; if (x & 1) B.insert(Q[Q.size() - 1]); else A.insert(Q[Q.size() - 1]); } void qb() { 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 = number_queried - x/2 + (x&1); ans += as; 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...