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"
#define pb push_back
#define ll long long
using namespace std;
string guess_sequence(int n) {
srand(time(0));
string ans;
int k = press("AB");
if(k >= 1) {
k = press("B");
if(k == 1)
ans += "B";
else
ans += "A";
}
else {
k = press("X");
if(k == 1)
ans += "X";
else
ans += "Y";
}
vector<char> ost;
if(ans[0] != 'A')
ost.pb('A');
if(ans[0] != 'B')
ost.pb('B');
if(ans[0] != 'X')
ost.pb('X');
if(ans[0] != 'Y')
ost.pb('Y');
int lst = -1;
for(int i = 2; i <= n; i++) {
if(i == n && lst == -1) {
k = press(ans + ost[0] + ans + ost[1]);
if(k == i) {
k = press(ans + ost[0]);
if(k == i)
ans += ost[0];
else
ans += ost[1];
}
else {
ans += ost[2];
}
}
else if(lst == -1) {
k = press(ans + ost[0] + ost[0] + ans + ost[1] + ost[1] + ans + ost[0] + ost[1]);
if(k == i + 1) {
k = press(ans + ost[0] + ost[0]);
if(k == i + 1)
ans += ost[0], ans += ost[0], i++;
else if(k == i)
ans += ost[0], ans += ost[1], i++;
else {
ans += ost[1], ans += ost[1], i++;
}
continue;
}
else if(k == i) {
k = press(ans + ost[1] + ost[2]);
if(k == i + 1) {
ans += ost[1], ans += ost[2], i++;
}
else if(k == i - 1) {
ans += ost[0], ans += ost[2], i++;
}
else {
ans += ost[1], ans += ost[0], i++;
}
}
else {
ans += ost[2];
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |