Submission #541212

#TimeUsernameProblemLanguageResultExecution timeMemory
541212collodelCombo (IOI18_combo)C++17
5 / 100
1 ms288 KiB
#include "combo.h"
#include <iostream>
using namespace std;

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

std::string guess_sequence(int N) {
	// trova il primo carattere
	int first;
	for(first = 0; first < 4; ++first) {
		bool found = 1;
		for(auto &c : choices) {
			int val = press(string(1, c) + choices[first]);
			if(val != 1) found = 0;
		}

		if(found)
			break;
	}

	string ans = string(1, choices[first]);

	while((int)ans.length() < N) {
		for(auto &c : choices) {
			if(c == choices[first]) continue;
			
			int r = press(ans + c);
			if(r == (int)ans.length()+1) {
				ans += c;
			}
		}
	}

	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...