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>
using namespace std;
template<typename T>
inline bool maxi(T &x, const T &val)
{
if (x < val) return x = val, true;
return false;
}
template<typename T>
inline bool mini(T &x, const T &val)
{
if (x > val) return x = val, true;
return false;
}
int press(string p);
char c[4] = {'A', 'B', 'X', 'Y'};
string guess_sequence(int n)
{
string ans = "";
if (press("AB")) {
if (press("A")) ans += "A";
else ans += "B", swap(c[0], c[1]);
}
else {
if (press("X")) ans += "X", swap(c[0], c[2]);
else ans += "Y", swap(c[0], c[3]);
}
while ((int)ans.size() < n - 1) {
string tmp = "";
for (int i = 1; i <= 3; i++) {
tmp += (ans + c[1] + c[i]);
}
tmp += (ans + c[2]);
int dak = press(tmp);
if (dak == (int)ans.size()) {
ans += c[3];
}
else if (dak == (int)ans.size() + 1) {
ans += c[2];
}
else ans += c[1];
}
if (press(ans + c[1]) == n) return ans + c[1];
if (press(ans + c[2]) == n) return ans + c[2];
return ans + c[3];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |