Submission #293838

#TimeUsernameProblemLanguageResultExecution timeMemory
293838amoo_safarCombo (IOI18_combo)C++17
5 / 100
1 ms200 KiB
#include "combo.h"

#include <bits/stdc++.h>


#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end();

using namespace std;

typedef pair<int, int> pii;
typedef string str;

char c[4] = {'A', 'B', 'X', 'Y'};

string guess_sequence(int n){
	str p = "";
	p += c[0];
	p += c[1];
	int res, id;
	res = press(p);
	if(res == 0){
		p = "";
		p += c[2];
		res = press(p);
		if(res) id = 2;
		else id = 3;
	} else {
		p = "";
		p += c[0];
		res = press(p);
		if(res) id = 0;
		else id = 1;
	}
	if(id) swap(c[id], c[0]);
	
	str com = ""; com += c[0];

	for(int i = 1; i + 1 < n; i++){
		p = "";
		p += com; p += c[1];
		p += com; p += c[2]; p += c[1];
		p += com; p += c[2]; p += c[2];
		p += com; p += c[2]; p += c[3];
		
		res = press(p);
		if(res == i) com += c[3];
		else if(res == i + 1) com += c[1];
		else if(res == i + 2) com += c[2];
		else assert(0);
	}
	p = com; p += c[1]; 
	p += com; p += c[2];
	if(press(p) == n){
		p = com;
		p += c[1];
		if(press(p) == n) com += c[1];
		else com += c[2];
	} else {
		com += c[3];
	}
	//cerr << "! " << com << '\n';
	return com;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...