# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
835431 | TheSahib | 버섯 세기 (IOI20_mushrooms) | C++14 | 2 ms | 308 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "mushrooms.h"
using namespace std;
const int BLOCK = 145;
vector<int> A, B;
int count_mushrooms(int n) {
if(n <= BLOCK * 2){
int ans = 1;
for (int i = 1; i < n; i++)
{
ans += use_machine({0, i}) == 0;
}
return ans;
}
A.push_back(0);
bool swp = false;
for (int i = 1; i < BLOCK * 2; ++i)
{
bool b = use_machine({0, i}) == 1;
if(b){
B.push_back(i);
}
else{
A.push_back(i);
}
}
int ans = A.size();
int cnt = 0;
if(A.size() < B.size()) {
swp = true;
swap(A, B);
}
for (int i = BLOCK * 2; i < n; i += A.size())
{
vector<int> v;
for(int j = i; j < i + A.size(); ++j){
v.push_back(A[j - i]);
v.push_back(j);
}
cnt += (use_machine(v) + 1) / 2;
}
if(!swp){
cnt = (n - BLOCK * 2) - cnt;
}
ans += cnt;
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |