This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Dedicated to my love, ivaziva
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = int64_t;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define dbg(x) cerr << #x << ": " << x << '\n';
string guess_sequence(int n) {
char f;
if (press("AB")) {
if (press("A"))
f = 'A';
else
f = 'B';
} else {
if (press("Y") == 1)
f = 'Y';
else
f = 'X';
}
string ans = "";
ans.push_back(f);
int sz = 1;
for (int i = 2; i < n; i++) {
if (f == 'A') {
int ret = press(ans + "Y" + ans + "XX" + ans + "XY" + ans + "XB");
if (ret == sz + 1)
ans.push_back('Y');
else if (ret == sz + 2)
ans.push_back('X');
else
ans.push_back('B');
} else if (f == 'B') {
int ret = press(ans + "Y" + ans + "XX" + ans + "XY" + ans + "XA");
if (ret == sz + 1)
ans.push_back('Y');
else if (ret == sz + 2)
ans.push_back('X');
else
ans.push_back('A');
} else if (f == 'X') {
int ret = press(ans + "Y" + ans + "AA" + ans + "AY" + ans + "AB");
if (ret == sz + 1)
ans.push_back('Y');
else if (ret == sz + 2)
ans.push_back('A');
else
ans.push_back('B');
} else if (f == 'Y') {
int ret = press(ans + "X" + ans + "AX" + ans + "AA" + ans + "AB");
if (ret == sz + 1)
ans.push_back('X');
else if (ret == sz + 2)
ans.push_back('A');
else
ans.push_back('B');
}
sz++;
}
if (sz == n) {
return ans;
}
if (f == 'A') {
if (press(ans + 'X') == n)
ans.push_back('X');
else if (press(ans + 'Y') == n)
ans.push_back('Y');
else
ans.push_back('B');
} else if (f == 'B') {
if (press(ans + 'X') == n)
ans.push_back('X');
else if (press(ans + 'Y') == n)
ans.push_back('Y');
else
ans.push_back('A');
} else if (f == 'X') {
if (press(ans + 'Y') == n)
ans.push_back('Y');
else if (press(ans + 'B') == n)
ans.push_back('B');
else
ans.push_back('A');
} else if (f == 'Y') {
if (press(ans + 'A') == n)
ans.push_back('A');
else if (press(ans + 'X') == n)
ans.push_back('X');
else
ans.push_back('B');
}
return ans;
}
/*int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cout.tie(nullptr); cerr.tie(nullptr);
return 0;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |