# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
933331 | SulA | Combo (IOI18_combo) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence(int N) {
string s;
vector<char> a(4) = {'A','B','X','Y'};
int x = press("AB");
if (x == 2) s += "AB";
else if (x == 1) {
s = (press("A") == 1 ? "A" : "B");
}
else {
s = (press("X") == 1 ? "X" : "Y");
}
if (N == 1) return s;
int first = find(a.begin(), a.end(), s[0]);
erase(first, a.begin(), a.end());
for (int i = s.size(); i < n-1; i++) {
x = press(s + a[0] + s + a[1] + a[0] + s + a[1] + a[1] + s + a[1] + a[2]);
if (x == s.size()) s += a[2];
else if (x == s.size() + 1) s += a[1];
else s += a[2];
}
x = press(s + a[0]);
if (x > s.size()) return s + a[0];
else if (press(s + a[1]) > s.size()) return s + a[1];
return s + a[2];
}