# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
623918 | ollel | Counting Mushrooms (IOI20_mushrooms) | C++14 | 1 ms | 208 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |