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;
using ll = long long;
string guess_sequence(int n) {
vector<string> pos = {"A", "B", "X", "Y"};
string ans = "";
if(press("AB")) {
if(press("A")) ans += "A";
else ans += "B";
}
else {
if(press("X")) ans += "X";
else ans += "Y";
}
string res = to_string(ans[0]);
for(int i = 1; i < n; i++) {
if(i == n-1) {
string curr = "";
string last;
for(auto it : pos) {
if(it == res) continue;
if(curr.length() == 2) {
last = it;
}
else curr += it;
}
if(press(curr)) {
string curr1 = to_string(curr[0]), curr2 = to_string(curr[1]);
if(press(curr1)) ans += curr1;
else ans += curr2;
}
else ans += last;
}
else {
string f = "", s = "", t = "";
for(auto it : pos) {
if(it == res) continue;
if(f == "") f = it;
else if(s == "") s = it;
else t = it;
}
string curr = ans + f + s + ans + f + f + ans + f + t + ans + s;
int k = press(curr);
if(k == 2) {
ans += f;
}
else if(k == 1) {
ans += s;
}
else ans += t;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |