제출 #604443

#제출 시각아이디문제언어결과실행 시간메모리
604443gagik_2007버섯 세기 (IOI20_mushrooms)C++17
0 / 100
1 ms208 KiB
#include "mushrooms.h"
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <limits>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef ll itn;

#define ff first
#define ss second

ll n;

int count_mushrooms(int N) {
	n = N;
	pair<int, int>sm;
	vector<int>ask = { 0,1 };
	int vl = use_machine(ask);
	int anh = -1;
	bool sma = true;
	ll ans = 0;
	if (vl == 0) {
		if (n == 2)return 2;
		sm = { 0,1 };
		anh = 2;
		ans = 2;
	}
	else {
		if (n == 2)return 1;
		ask = { 1,2 };
		vl = use_machine(ask);
		anh = 3;
		if (vl == 1) {
			if (n == 3)return 2;
			sm = { 0,2 };
			ans = 2;
		}
		else {
			if (n == 3)return 1;
			sm = { 1,2 };
			ans = 1;
			sma = false;
		}
	}
	for (int i = anh; i < n; i += 2) {
		if (i == n - 1) {
			ask = { 0,i };
			vl = use_machine(ask);
			if (vl) {
				ans++;
			}
			break;
		}
		ask = { sm.ff,i,sm.ss,i + 1 };
		vl = use_machine(ask);
		if (sma) {
			switch (vl)
			{
			case 0:
				break;
			case 1:
				ans += 1;
				break;
			case 2:
				ans += 1;
				break;
			case 3:
				ans += 2;
				break;
			}
		}
		else {
			switch (vl)
			{
			case 0:
				ans += 2;
				break;
			case 1:
				ans += 1;
				break;
			case 2:
				ans += 1;
				break;
			case 3:
				break;
			}
		}
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...