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;
#define _size(x) (int)x.size()
string guess_sequence(int n) {
string ans = "";
int x = press("AB");
if (x) {
x = press("A");
if (x) ans += 'A';
else ans += 'B';
}
else {
x = press("X");
if (x) ans += 'X';
else ans += 'Y';
}
string t = "ABXY";
vector<char> ch;
for (int i = 0; i < 4; i++) if (t[i] != ans[0]) ch.push_back(t[i]);
if (_size(ans) == n) return ans;
while (_size(ans) < n - 1) {
x = press(ans + ch[0] + ch[0] + ans + ch[0] + ch[1] + ans + ch[0] + ch[2] + ans + ch[1]);
if (x - _size(ans) == 2) ans += ch[0];
else if (x - _size(ans) == 1) ans += ch[1];
else ans += ch[2];
}
x = press(ans + ch[0] + ans + ch[1]);
if (x - _size(ans) == 0) ans += ch[2];
else if (press(ans + ch[0]) == n) ans += ch[0];
else ans += ch[1];
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |