# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
303605 | galca | 버섯 세기 (IOI20_mushrooms) | C++14 | 12 ms | 372 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
using namespace std;
int count_mushrooms(int n) {
vector<int> knownZeros;
vector<int> knownOnes;
knownZeros.push_back(0);
// find one more, or two 1s
int i = 1;
while ((knownZeros.size() < 2) && (knownOnes.size() < 2)) {
int c = use_machine({ 0, i });
if (c) {
knownOnes.push_back(i);
}
else {
knownZeros.push_back(i);
}
++i;
if (i == n) {
return knownZeros.size();
}
}
vector<int> fours;
bool isZero = false;
if (knownZeros.size() == 2) {
fours.push_back(knownZeros[0]);
fours.push_back(0);
fours.push_back(knownZeros[1]);
fours.push_back(0);
isZero = true;
}
else {
fours.push_back(knownOnes[0]);
fours.push_back(0);
fours.push_back(knownOnes[1]);
fours.push_back(0);
}
if (n <= 200) {
for (; i < n; i++) {
int c = use_machine({ 0, i });
if (c) {
knownOnes.push_back(i);
}
else {
knownZeros.push_back(i);
}
}
return knownZeros.size();
}
for (; i < 200; i += 2) {
fours[1] = i;
fours[3] = i+1;
int c = use_machine(fours);
switch (c) {
case 0:
if (isZero) {
knownZeros.push_back(i);
knownZeros.push_back(i+1);
}
else {
knownOnes.push_back(i);
knownOnes.push_back(i + 1);
}
break;
case 1:
if (isZero) {
knownZeros.push_back(i);
knownOnes.push_back(i+1);
}
else {
knownOnes.push_back(i);
knownZeros.push_back(i + 1);
}
break;
case 2:
if (isZero) {
knownOnes.push_back(i);
knownZeros.push_back(i+1);
}
else {
knownZeros.push_back(i);
knownOnes.push_back(i + 1);
}
break;
case 3:
if (isZero) {
knownOnes.push_back(i);
knownOnes.push_back(i + 1);
}
else {
knownZeros.push_back(i);
knownZeros.push_back(i + 1);
}
break;
}
}
int totalZeros = knownZeros.size();
while (i < n) {
vector<int> m;
if (knownOnes.size() >= knownZeros.size()) {
for (int j = 0; j < knownOnes.size(); j++) {
if ((i + j) < n) {
m.push_back(knownOnes[j]);
m.push_back(i + j);
}
}
int c = use_machine(m);
if (c & 1) {
++totalZeros;
--c;
knownZeros.push_back(m[m.size() - 1]);
}
totalZeros += c / 2;
i += knownOnes.size();
}
else {
for (int j = 0; j < knownZeros.size(); j++) {
if ((i + j) < n) {
m.push_back(knownZeros[j]);
m.push_back(i + j);
}
}
int c = use_machine(m);
if (c & 1) {
++c;
knownOnes.push_back(m[m.size() - 1]);
}
totalZeros += (m.size() - c) / 2;
i += knownZeros.size();
}
}
return totalZeros;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |