| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1079016 | Trumling | 버섯 세기 (IOI20_mushrooms) | C++14 | 6 ms | 600 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 99999999999999999
#define MOD 1000000007
#define all(x) x.begin(),x.end()
int count_mushrooms(int n) {
	if(n<220)
	{
	vector<int> m(3,0);
	ll c2=1;
	for(int i=1;i<n-1;i+=2)
	{
		m[0]=i;
		m[2]=i+1;
		int c1 = use_machine(m);
		c2+=2-c1;
	}
	if(n%2==0)
	{
		m.clear();
		m.assign(2,0);
		m[1]=n-1;
		int c1 = use_machine(m);
		if(!c1)
		c2++;
	}
	return c2;
	}
	vector<int>A,B;
	A.pb(0);
	int i;
	ll tf=1;
	ll a=use_machine({0,1});
	if(a==0)
	{
		A.pb(-1);
		A.pb(1);
	}
	else
	{
		tf=2;
		B.pb(1);
		a=use_machine({0,2});
		if(a==0)
		{
			A.pb(-1);
			A.pb(2);
		}
		else
		{
			B.pb(-1);
			B.pb(2);
			tf=3;
		}
	}
	for(i=((tf==1)?2:3);i<282;i+=2)
	{
		if(tf<=2)
			{
			ll ans=use_machine({0,i,A[2],i+1});
			if(ans<2)
			{
			A.pb(-1);
			A.pb(i);
			}
			else
			{
			if(B.size()!=0)
				B.pb(-1);
			B.pb(i);
			}
			if(A.size()==281 || B.size()==281)
				break;
			if(ans%2==0)
			{
			A.pb(-1);
			A.pb(i+1);
			}
			else
			{
			if(B.size()!=0)
				B.pb(-1);
			B.pb(i+1);
			}
			if(A.size()==281 || B.size()==281)
			{
				i++;
				break;
			}
			}
		else
			{
			ll ans=use_machine({1,i,2,i+1});
			if(ans>=2)
			{
			A.pb(-1);
			A.pb(i);
			}
			else
			{
			if(B.size()!=0)
				B.pb(-1);
			B.pb(i);
			}
			if(A.size()==281 || B.size()==281)
				break;
			if(ans%2)
			{
			A.pb(-1);
			A.pb(i+1);
			}
			else
			{
			if(B.size()!=0)
				B.pb(-1);
			B.pb(i+1);
			}
			if(A.size()==281 || B.size()==281)
			{
				i++;
				break;
			}
			}
	}
	ll counta=A.size()/2 + 1;
	i++;
	
	for(i=i;i<n;i+=140)
	{
	if(A.size()==281)
	{
		if(i+140<=n)
		{
		for(int j=0;j<140;j++)
			A[j*2+1]=i+j;
		
		ll ans=use_machine(A);
		counta+=140-ans/2;
		continue;
		}
		vector<int>p;
		int j;
		for(j=0;j<n-i;j++)
			{
				p.pb(A[j*2]);
				p.pb(i+j);
			}
		p.pb(A[j*2]);
		ll ans=use_machine(p);
		counta+=(n-i)-ans/2;
	}
	else
	{
		if(i+140<=n)
		{
		for(int j=0;j<140;j++)
			B[j*2+1]=i+j;
		
		ll ans=use_machine(B);
		counta+=ans/2;
		continue;
		}
		vector<int>p;
		int j;
		for(j=0;j<n-i;j++)
			{
				p.pb(B[j*2]);
				p.pb(i+j);
			}
		p.pb(B[j*2]);
		ll ans=use_machine(p);
		counta+=ans/2;
	}
	}
	return counta;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
