Submission #199759

#TimeUsernameProblemLanguageResultExecution timeMemory
199759detaomegaCombo (IOI18_combo)C++14
0 / 100
37 ms476 KiB
//#include "combo.h"
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
char used[4] = {'A', 'B', 'X', 'Y'};

string guess_sequence(int N) {
	string ans;
	char No;
	int val;
	val = press("AB");
	if(val == 2) {
		No = 'A';
		ans += 'A';
	}
	else if(val == 1) {
		val = press("A");
		if(val == 1) {
			No = 'A';
			ans += 'A';
		}
		else {
			No = 'B';
			ans += 'B'; 
		}
	}
	else {
		val = press("X");
		if(val == 1) {
			No = 'X';
			ans += 'X';
		}
		else {
			No = 'Y';
			ans += 'Y'; 
		}
	}
	if(N == 1) return ans;
	vector<char> vt;
	for(int i=0; i<4; i++) {
		if(No == used[i]) continue;
		vt.push_back(used[i]);
	}
	for(int i=1; i<N-1; i++) {
		string s1 = ans+vt[0]+vt[0], s2 = ans+vt[0]+vt[1], s3 = ans+vt[0]+vt[2], s4 = ans + vt[1];
		int tmp = press(s1+s2+s3+s4);
		if(tmp-i== -1) {
			ans += vt[2];
		} 
		else if(tmp == i) {
			ans += vt[1];
		}
		else {
			ans += vt[0];
		}
	}
	bool fg = 0;
	for(int i=0; i<2; i++) {
		if(press(ans + vt[i]) == N) {
			fg = 1;
			ans+= vt[i];
			break;
		}
	}
	if(!fg) ans += vt[2];
 	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...