Submission #998541

#TimeUsernameProblemLanguageResultExecution timeMemory
998541overwatch9Combo (IOI18_combo)C++17
30 / 100
32 ms932 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
	string ans = "AB";
   	int res = press(ans);
	// cout << "RES1: " << res << '\n';
   	if (res >= 1) {
     	ans = "A";
      	res = press(ans);
		if (res == 0)
			ans = "B";
  	} else {
		ans = "X";
		res = press(ans);
		if (res == 0)
			ans = "Y";
	}
	vector <char> c(3);
	if (ans[0] == 'A')
		c = {'B', 'X', 'Y'};
	if (ans[0] == 'B')
		c = {'A', 'X', 'Y'};
	if (ans[0] == 'X')
		c = {'A', 'B', 'Y'};
	if (ans[0] == 'Y')
		c = {'A', 'B', 'X'};

	for (int i = 1; i < N; i++) {
		string s = ans;
		// s.push_back('B');
		// s.append(ans);
		// s.append("XB");
		// s.append(ans);
		// s.append("XX");
		// s.append(ans);
		// s.append("XY");
		// cout << "guess: " << s << '\n';
		// res = press(s);
		// cout << "result: " << res << '\n';
		// if (res == 1)
		// 	ans.push_back('B');
		// else if (res == 2)
		// 	ans.push_back('X');
		// else
		// 	ans.push_back('Y');
		for (int j = 0; j < 2; j++) {
			s.push_back(c[j]);
			res = press(s);
			if (res == i+1) {
				ans.push_back(c[j]);
				break;
			}
			s.pop_back();
		}
		if ((int)ans.size() < i+1)
			ans.push_back(c[2]);
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...