# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
604934 | Tigryonochekk | Counting Mushrooms (IOI20_mushrooms) | C++17 | 9 ms | 316 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include "mushrooms.h"
#include <vector>
#define ll long long
using namespace std;
const int wtf = 200;
int count_mushrooms(int n) {
vector<int> a, b;
a.push_back(0);
int ans = 1;
int x = min(wtf, n);
for (int i = 1; i < x; i++) {
int u = use_machine({ 0, i });
if (u == 0) {
a.push_back(i);
ans++;
}
else {
b.push_back(i);
}
}
if (x == n)
return ans;
if (a.size() >= b.size()) {
int c = a.size();
int i = x;
while (i + (c - 1) - 1 < n) {
vector<int> m;
m.push_back(a[0]);
for (int j = 1; j < c; j++) {
m.push_back(i);
i++;
m.push_back(a[j]);
}
if (m.size() >= 1) {
int k = use_machine(m);
ans += c - 1 - k / 2;
}
}
vector<int> m;
m.push_back(a[0]);
int j = 1;
for (; i < n; i++) {
m.push_back(i);
m.push_back(a[j]);
j++;
}
if (m.size() >= 1) {
int k = use_machine(m);
ans += j - 1 - k / 2;
}
}
else {
int c = b.size();
int i = x;
while (i + (c - 1) - 1 < n) {
vector<int> m;
m.push_back(b[0]);
for (int j = 1; j < c; j++) {
m.push_back(i);
i++;
m.push_back(b[j]);
}
if (m.size() > 1) {
int k = use_machine(m);
ans += k / 2;
}
}
vector<int> m;
m.push_back(b[0]);
int j = 1;
for (; i < n; i++) {
m.push_back(i);
m.push_back(b[j]);
j++;
}
if (m.size() >= 1) {
int k = use_machine(m);
ans += k / 2;
}
}
return ans;
}
/*
8
0 1 1 0 1 0 1 0
11
0 1 1 1 1 1 1 0 0 0 0
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |