Submission #421430

#TimeUsernameProblemLanguageResultExecution timeMemory
421430amoo_safarCombo (IOI18_combo)C++17
100 / 100
44 ms684 KiB
#include "combo.h"

#include <bits/stdc++.h>

using namespace std;

typedef string str;

str guess_sequence(int n){
	// std::string p = "";
	// for (int i = 0; i < 4 * N; ++i) {
	// p += 'A';
	// }
	// int coins = press(p);
	// std::string S = "";
	// for (int i = 0; i < N; ++i) {
	// S += 'A';
	// }
	// return S;
	str al = "ABXY";
	if( press(al.substr(0, 2)) == 0) swap(al[0], al[2]), swap(al[1], al[3]);
	if( press(al.substr(0, 1)) == 0) swap(al[0], al[1]);
	// for(int i = 1; i < 4; i++){
	// 	if( press( al.substr(i, 1) ) ){
	// 		swap(al[i], al[0]);
	// 		break;
	// 	}
	// }
	str ans = "";
	ans += al[0];
	if(n == 1)
		return ans;
	for(int i = 1; i < n - 1; i++){
		str q = "";
		q += ans + al[1];
		q += ans + al[2] + al[1];
		q += ans + al[2] + al[2];
		q += ans + al[2] + al[3];
		int res = press(q);
		if(res == i) ans += al[3];
		if(res == i + 1) ans += al[1];
		if(res == i + 2) ans += al[2];
	}
	for(int i = 2; i < 4; i++){
		if( press( ans + al[i] ) == n ){
			return ans + al[i];
		}
	}
	return ans + al[1];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...