# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
718230 | baojiaopisu | 버섯 세기 (IOI20_mushrooms) | C++14 | 9 ms | 556 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include <vector>
#include <iostream>
#include <algorithm>
#include <array>
#include <random>
#include <chrono>
using namespace std;
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int count_mushrooms(int n) {
vector<int> a, b;
vector<int> not_solved;
for(int i = 1; i < n; i++) not_solved.pb(i);
a.pb(0);
shuffle(not_solved.begin(), not_solved.end(), rng);
int res = 1;
while(not_solved.size()) {
if(a.size() >= b.size()) {
vector<int> r;
while(not_solved.size() && r.size() < a.size()) {
r.pb(not_solved.back());
not_solved.pop_back();
}
vector<int> ask;
for(int i = 0; i < (int)a.size(); i++) {
if(i < r.size()) ask.pb(r[i]);
ask.pb(a[i]);
}
int x = use_machine(ask);
res += r.size() - ((x + 1) / 2);
for(int i = 1; i <= 5; i++) {
if(r.empty() || a.size() >= 150) break;
if(a.size() == 1 || r.size() == 1) {
int u = r.back();
r.pop_back();
if(use_machine({a[0], u})) {
b.pb(u);
} else a.pb(u);
} else {
int u = r.back();
r.pop_back();
int v = r.back();
r.pop_back();
int d = use_machine({a[0], u, a[1], v});
if(d & 1) b.pb(v); else a.pb(v);
if(d & 2) b.pb(u); else a.pb(u);
}
}
} else {
vector<int> r;
while(not_solved.size() && r.size() < b.size()) {
r.pb(not_solved.back());
not_solved.pop_back();
}
vector<int> ask;
for(int i = 0; i < (int)b.size(); i++) {
if(i < r.size()) ask.pb(r[i]);
ask.pb(b[i]);
}
int x = use_machine(ask);
res += (x + 1) / 2;
for(int i = 1; i <= 5; i++) {
if(r.empty() || b.size() >= 150) break;
if(b.size() == 1 || r.size() == 1) {
int u = r.back();
r.pop_back();
if(use_machine({b[0], u})) {
a.pb(u);
} else b.pb(u);
} else {
int u = r.back();
r.pop_back();
int v = r.back();
r.pop_back();
int d = use_machine({b[0], u, b[1], v});
if(d & 1) a.pb(v); else b.pb(v);
if(d & 2) a.pb(u); else b.pb(u);
}
}
}
}
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |