# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
432573 | saleh | 버섯 세기 (IOI20_mushrooms) | C++17 | 121 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"//
#include <bits/stdc++.h>
using namespace std;
int count_mushrooms(int n) {
vector<int> m = {0, 1}, nat;
for (int i = 0; i < n; i++) nat.push_back(0);
nat[0] = 1;
int c1 = use_machine(m);
if (c1 > 0) nat[1] = 2;
else nat[1] = 1;
if (n == 2) return 2 - c1;
m = {0, 2};
int c2 = use_machine(m);
if (c2 > 0) nat[2] = 2;
else nat[2] = 1;
int tmp = -1, pmt = -1;
if (c1 == 0) {
tmp = 0;
pmt = 1;
}
if (c2 == 0) {
tmp = 0;
pmt = 2;
}
if (c1 == c2 && c1 == 1) {
tmp = 1;
pmt = 2;
for (int i = 3; i + 1 < n; i += 2) {
m = {tmp, i, pmt, i + 1};
int chi = use_machine(m);
if (chi % 2 == 1) nat[i + 1] = 1;
else nat[i + 1] = 2;
if (chi >= 2) nat[i] = 1;
else nat[i] = 2;
}
if (n % 2 == 0) {
m = {tmp, n - 1};
if (use_machine(m) > 0) nat[n - 1] = 1;
else nat[n - 1] = 2;
}
} else {
for (int i = 3; i + 1 < n; i += 2) {
m = {tmp, i, pmt, i + 1};
int chi = use_machine(m);
if (chi % 2 == 1) nat[i + 1] = 2;
else nat[i + 1] = 1;
if (chi >= 2) nat[i] = 2;
else nat[i] = 1;
}
if (n % 2 == 0) {
m = {tmp, n - 1};
if (use_machine(m) > 0) nat[n - 1] = 2;
else nat[n - 1] = 1;
}
}
return count(nat.begin(), nat.end(), 1);
}
//int main() {}//
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |