# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
824529 | NothingXD | Counting Mushrooms (IOI20_mushrooms) | C++17 | 2 ms | 464 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.
#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 = 141;
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);
}
if (A.size() < sq){
swap(A, B);
flg = !flg;
}
for (int i = A.size()+B.size(); i < n; i += 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);
tmp = (tmp+1) / 2;
for (int j = 0; j < tmp; j++){
B.push_back(0);
}
}
return (flg? B.size(): n-B.size());
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |