제출 #1313547

#제출 시각아이디문제언어결과실행 시간메모리
1313547PlayVoltz버섯 세기 (IOI20_mushrooms)C++20
10 / 100
53 ms612 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;

const int X=120;

#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

int count_mushrooms(int n){
	int p=1, ans=0;
	vector<int> a(1, 0), b;
	while ((a.size()<X||b.size()<X)&&p<n){
		vector<int> temp;
		temp.pb(a[0]);
		temp.pb(p);
		int res=use_machine(temp);
		if (res)b.pb(p);
		else a.pb(p);
		++p;
	}
	if (a.size()>=X){
		while (p<n){
			vector<int> temp;
			for (int i=0; i<X&&p<n; ++i)temp.pb(a[i]), temp.pb(p), ++p;
			int res=use_machine(temp);
			ans+=temp.size()/2-(res/2+res%2);
		}
	}
	else{
		while (p<n){
			vector<int> temp;
			for (int i=0; i<X&&p<n; ++i)temp.pb(b[i]), temp.pb(p), ++p;
			int res=use_machine(temp);
			ans+=res/2+res%2;
		}
	}
	return ans+a.size();
}
#Verdict Execution timeMemoryGrader output
Fetching results...