답안 #1054645

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1054645 2024-08-12T11:21:15 Z Gromp15 버섯 세기 (IOI20_mushrooms) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
#include "mushrooms.h"
#define sz(x) (int)x.size()
using namespace std;

const int len = 200;

int count_mushrooms(int n) {
	vector<int> A, B;
	for (int i = 1; i < min(n, len + 1); i++) {
		(use_machine({0, i}) ? B : A).push_back(i);
	}
	int ans = A.size() + 1;
	bool inv = 0;
	if (A.size() < B.size()) swap(A, B), inv = 1;
	vector<int> cur{A[0]};
	for (int j = len + 1, on = 1; j < n; j++) {
		if (on == sz(A)) {
			int res = use_machine(cur);
			ans += inv ? res / 2 : sz(cur) - sz(A) - res / 2;
			cur.clear();
			cur.emplace_back(A[0]);
			on = 1;
		}
		cur.emplace_back(j);
		cur.emplace_back(A[on++]);
	}
	if (cur.size() > 1) {
		int res = use_machine(cur);
		ans += inv ? res / 2 : sz(cur) - sz(A) - res / 2;
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Incorrect 1 ms 344 KB Answer is not correct.
7 Halted 0 ms 0 KB -