Submission #151269

#TimeUsernameProblemLanguageResultExecution timeMemory
151269dennisstar콤보 (IOI18_combo)C++11
5 / 100
3 ms256 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
char ar[]="ABXY";
string guess_sequence(int N) {
	string p = "";
	int i;
	p="AB";
	if (press(p)) {
		p="A";
		if (press(p)) p="A";
		else p="B";
	}
	else {
		p="X";
		if (press(p)) p="X";
		else p="Y";
	}
	for (i=0; i<4; i++) if (p[0]==ar[i]) {
		for (i=i+1; i<4; i++) ar[i-1]=ar[i];
		break;
	}
	string q;
	for (i=1; i<N-1; i++) {
		q="";
		q+=p; q+=ar[0]; q+=ar[0];
		q+=p; q+=ar[0]; q+=ar[1];
		q+=p; q+=ar[0]; q+=ar[2];
		q+=p; q+=ar[1];
		int ret=press(q);
		if (ret==i+2) p+=ar[0];
		else if (ret==i+1) p+=ar[1];
		else p+=ar[2];
	}
	p+=ar[0];
	if (press(p)==N) return p;
	p[N-1]=ar[1];
	if (press(p)==N) return p;
	p[N-1]=ar[2]; return p;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...