# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
546806 | LucaDantas | Counting Mushrooms (IOI20_mushrooms) | C++17 | 14 ms | 600 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;
mt19937 rng(random_device{}());
vector<int> color[2];
int count_mushrooms(int N) {
int cnt[2]{};
color[0] = {0};
vector<int> unknown(N-1);
iota(unknown.begin(), unknown.end(), 1);
shuffle(unknown.begin(), unknown.end(), rng);
// umas queries qqr aleatorias ai
for(int i = 0; i < 5; i++) {
vector<int> qr(N);
iota(qr.begin(), qr.end(), 0);
shuffle(qr.begin(), qr.end(), rng);
while(qr.size() > N/4 && qr.size() > 10) qr.pop_back();
use_machine(qr);
}
while(unknown.size()) {
int usar = color[1].size() > color[0].size(); // escolho o grupo que tem mais gente pra usar
int sz = color[usar].size();
vector<int> qr;
for(int i = 0; i < sz && unknown.size(); i++, unknown.pop_back())
qr.push_back(color[usar][i]), qr.push_back(unknown.back());
int resp = use_machine(qr);
color[usar ^ (resp&1)].push_back(qr.back());
cnt[usar^1] += resp/2;
cnt[usar] += (qr.size() / 2 - 1) - resp/2;
}
return cnt[0] + color[0].size();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |