# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1052356 | aykhn | 버섯 세기 (IOI20_mushrooms) | C++17 | 6 ms | 600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
int B = 137;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int count_mushrooms(int n)
{
for (int i = 1; i <= 200; i++)
{
if (2 * i + (n + i - 1) / i <= 2 * B + (n + B - 1) / B) B = i;
}
vector<int> v[2];
vector<int> o(n);
iota(o.begin(), o.end(), 0);
shuffle(o.begin() + 1, o.end(), rng);
v[0] = {0};
int i = 1;
for (; i < n && max(v[0].size(), v[1].size()) < B + 1; i += 2)
{
if (i + 1 < n)
{
int x = use_machine({0, o[i], o[i + 1]});
if (x == 0) v[0].push_back(o[i]), v[0].push_back(o[i + 1]);
else if (x == 2) v[1].push_back(o[i]), v[0].push_back(o[i + 1]);
else
{
v[1].push_back(o[i + 1]);
if (!use_machine({0, o[i]})) v[0].push_back(o[i]);
else v[1].push_back(o[i]);
}
}
else v[use_machine({0, o[i]})].push_back(o[i]);
}
int res = 0;
for (int j = i; j < n; j += B)
{
vector<int> q;
int sz = min(n, j + B) - j;
for (int k = j; k < min(n, j + B); k++)
{
if (v[0].size() > v[1].size())
{
q.push_back(v[0][k - j]);
q.push_back(o[k]);
}
else
{
q.push_back(v[1][k - j]);
q.push_back(o[k]);
}
}
if (v[0].size() > v[1].size())
{
q.push_back(v[0].back());
res += sz - (use_machine(q) / 2);
}
else
{
q.push_back(v[1].back());
res += use_machine(q) / 2;
}
}
return res + v[0].size();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |