제출 #601948

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


#define pb push_back


#define MAX_INT 100


int count_mushrooms(int n)
{
	vector <int> blue{0};
	vector <int> red;

	int i;
	int ans=0;

	for(i=1;i<n;)
	{
		vector <int> query;

		for(int j=0;j<max(blue.size(),red.size()) && i<n;j++,i++)
		{
			if(blue.size()>red.size())
			{
				query.pb(blue[j]);
			}

			else
			{
				query.pb(red[j]);
			}

			query.pb(i);
		}

		int res=use_machine(query);

		if(blue.size()>red.size())
		{
			if(res%2==0)
			{
				blue.pb(i-1);
			}

			else
			{
				red.pb(i-1);
			}

			ans+=query.size()/2-1-res/2;
		}

		else
		{
			if(res%2==0)
			{
				red.pb(i-1);
			}

			else
			{
				blue.pb(i-1);
			}

			ans+=res/2;
		}
	}

	ans+=blue.size();


	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:24:16: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   24 |   for(int j=0;j<max(blue.size(),red.size()) && i<n;j++,i++)
      |               ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...