# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
305919 | myungwoo | Counting Mushrooms (IOI20_mushrooms) | C++17 | 11 ms | 416 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
int count_mushrooms(int N)
{
int K = 137;
vector<int> arr[2] = {{0}, {}};
int pt = 1;
// Step 1: Check type of mushroom one by one
while (pt < N){
arr[use_machine({0, pt})].push_back(pt);
pt++;
if (arr[0].size() >= 2 || arr[1].size() >= 2) break;
}
// Step 2: Check type of mushroom two by one
while (pt < N){
int t = arr[1].size() >= 2;
vector<int> test = {arr[t][0], pt, arr[t][1]};
if (pt+1 < N) test.push_back(pt+1);
int res = use_machine(test);
arr[res>>1&1^t].push_back(pt);
if (pt+1 < N) arr[res&1^t].push_back(pt+1);
pt += 2;
if (arr[0].size() >= K || arr[1].size() >= K) break;
}
// Step 3: Count number of type 0 mushrooms K by one
int zero_count = arr[0].size();
while (pt < N){
int t = arr[1].size() >= K;
vector<int> test;
for (int i=0;pt+i<N&&i<K;i++){
test.push_back(arr[t][i]);
test.push_back(pt+i);
}
int res = use_machine(test);
int cnt = res+1>>1;
if (!t) cnt = test.size()/2-cnt;
zero_count += cnt;
pt += K;
}
return zero_count;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |