제출 #1235626

#제출 시각아이디문제언어결과실행 시간메모리
1235626jellybeanCombo (IOI18_combo)C++20
5 / 100
0 ms408 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define dd(x) cout<<#x<<" is "<<x<<endl;

void getnext(string &s, string &t){
	int n = s.length();
	
	string query = "";
	for(int i=0; i<3; i++){
		query += s;
		query += t[0]; query += t[i];
	}
	query += s;
	query += t[1];
	
	int x = press(query);
	if(x == n+2) s+=t[0];
	else if(x==n+1) s+=t[1];
	else s+=t[2];
}

string guess_sequence(int N) {
	int n=N;
	string k,t;
	if(press("AB")){
		if(press("A")) k="A", t="BXY";
		else k="B", t="AXY";
	} else {
		if(press("X")) k="X", t="ABY";
		else k="Y", t="ABX";
	}
	
	for(int i=1; i<n-1; i++) getnext(k,t);
	
	if(press(k+t[0]) == n) k+=t[0];
	else if(press(k+t[1])==n) k+=t[1];
	else k+=t[2];
	
	return k;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...