답안 #305730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305730 2020-09-23T21:56:21 Z arthurconmy 버섯 세기 (IOI20_mushrooms) C++14
0 / 100
3 ms 256 KB
#ifndef ARTHUR_LOCAL
	#include "mushrooms.h"
#endif

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define len(x) int((x).size())

#ifdef ARTHUR_LOCAL
int use_machine(vector<int> V)
{
	for(auto v:V)
	{
		cout << v << " ";
	}
	cout << endl;

	if(V[1] == 3) return 1;
	if(V[1] == 2) return 0;
	if(V[1] == 1) return 1;

	int x;
	cin>>x;

	return x;
}
#endif

int count_mushrooms(int n) 
{
	vector<int> indices;
	for(int i=1; i<n; i++) indices.push_back(i);

	vector<int> As;
	vector<int> Bs;

	for(int i=1; i<=200 && !indices.empty(); i++)
	{
		int cur = use_machine({0,indices.back()});

		if(cur==1) Bs.push_back(indices.back());
		else As.push_back(indices.back());

		indices.pop_back();
	}

	int no_As = len(As) + 1;

	if(len(As)>=len(Bs))
	{
		// reverse(As.begin(),As.end());
		// As.push_back(0);
		// reverse(As.begin());

		while(!indices.empty())
		{
			vector<int> cur;

			while(!indices.empty() && len(cur) <= len(As))
			{
				cur.push_back(indices.back());
				indices.pop_back();
			}

			vector<int> req = {0};
		
			for(int i=0; i<len(cur); i++)
			{
				req.push_back(cur[i]);
				if(i<len(As)) req.push_back(As[i]);
			}

			int curbs = int((use_machine(req)+1)/2);
			no_As += len(cur) - curbs;

			return -1;
		}

		return no_As;
	}

	else
	{
		while(!indices.empty())
		{
			vector<int> cur;

			while(!indices.empty() && len(cur) < len(Bs))
			{
				cur.push_back(indices.back());
				indices.pop_back();
			}

			vector<int> req = {0};

			for(int i=0; i<len(cur); i++)
			{
				req.push_back(Bs[i]);
				req.push_back(cur[i]);
			}

			no_As += int((use_machine(req)+1)/2);
		}

		return no_As;
	}
}

#ifdef ARTHUR_LOCAL
int main()
{
	cout << "ANS: " << count_mushrooms(4) << endl;
}
#endif
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Incorrect 3 ms 256 KB Answer is not correct.
7 Halted 0 ms 0 KB -