# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1015621 | jairRS | 버섯 세기 (IOI20_mushrooms) | C++17 | 2 ms | 344 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include <iostream>
using namespace std;
int count_mushrooms(int n)
{
if (n <= 226)
{
int ans = 0;
for (int i = 1; i < n; i++)
{
int x = use_machine({0, i});
if (x == 0)
ans++;
}
return ans + 1;
}
// n > 226
int x = 101;
vector<int> A, B;
for (int i = 1; i <= 2 * x; i++) // habia i += 2
{
int query = use_machine({0, i});
if (query == 0)
A.push_back(i);
else
B.push_back(i);
}
char big_group;
vector<int> group;
if (A.size() > B.size())
{
group = A;
big_group = 'A';
}
else
{
group = B;
big_group = 'B';
}
int ans = 0;
for (int i = 2 * x + 1; i < n; i++)
{
vector<int> query = {group[0]}; // A ? A ? A ? A ? A ? A ? A
// ^
int next_mush = 1;
int j = i;
int unknown = 0;
for (; j < i + x - 1; j++)
{
if (j >= n)
break;
query.push_back(j);
query.push_back(group[next_mush]);
unknown++;
next_mush++;
}
i = j;
int res = use_machine(query);
// caso: terminamos temprano A ? A ? A
if (big_group == 'A')
ans += unknown - res / 2;
else
ans += res / 2;
}
return 1 + A.size() + ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |