Submission #413634

#TimeUsernameProblemLanguageResultExecution timeMemory
413634LastRonin콤보 (IOI18_combo)C++14
100 / 100
40 ms508 KiB
#include <bits/stdc++.h>
#include "combo.h"
#define pb push_back
#define ll long long
using namespace std;

string guess_sequence(int n) { 	
	srand(time(0));
	string ans;
	int k = press("AB");
	if(k >= 1) {
		k = press("B");
		if(k == 1)
			ans += "B";
		else
			ans += "A";
	}
	else {
		k = press("X");
		if(k == 1)
			ans += "X";
		else
			ans += "Y";
	}
	vector<char> ost;
	if(ans[0] != 'A')
		ost.pb('A');
	if(ans[0] != 'B')
		ost.pb('B');
	if(ans[0] != 'X')
		ost.pb('X');
	if(ans[0] != 'Y')
		ost.pb('Y');
	int lst = -1;
	for(int i = 2; i <= n; i++) {
		if(i == n && lst == -1) {
			k = press(ans + ost[0] + ans + ost[1]);
			if(k == i) {
				k = press(ans + ost[0]);
				if(k == i)
					ans += ost[0];
				else
					ans += ost[1];
			}
			else {
				ans += ost[2];
			}
		}
		else if(lst == -1) {
			k = press(ans + ost[0] + ost[0] + ans + ost[1] + ost[1] + ans + ost[0] + ost[1]);
			if(k == i + 1) {
				k = press(ans + ost[0] + ost[0]);
				if(k == i + 1) 
					ans += ost[0], ans += ost[0], i++;
				else if(k == i) 
					ans += ost[0], ans += ost[1], i++;
				else {
					ans += ost[1], ans += ost[1], i++;
				}
				continue;
			}
			else if(k == i) {
				k = press(ans + ost[1] + ost[2]);
				if(k == i + 1) {
					ans += ost[1], ans += ost[2], i++;
				}
				else if(k == i - 1) {
					ans += ost[0], ans += ost[2], i++;															
				}
				else {
					ans += ost[1], ans += ost[0], i++;
				}
			}
			else {
				ans += ost[2];
			}
		}
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...