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>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
using namespace std;
#define pb push_back
#include "combo.h"
string guess_sequence(int N) {
vector<char> btns = {'A', 'B', 'X', 'Y'};
char fst;
for (char c : btns) {
string p = "";
p += c;
int coins = press(p);
if (coins != 0) {
fst = c;
break;
}
}
vector<char> oth;
if (N == 1) {
string res = "";
res += fst;
return res;
}
for (char c : btns) {
if (c != fst) oth.pb(c);
}
string ans = "";
ans += fst;
rep(i, 1, N - 1) {
string p = "";
p += ans;
p += oth[0];
p += oth[0];
p += ans;
p += oth[0];
p += oth[1];
p += ans;
p += oth[0];
p += oth[2];
p += ans;
p += oth[1];
int coins = press(p);
if (coins == i)
ans += oth[2];
else if (coins == i + 1)
ans += oth[1];
else if (coins == i + 2)
ans += oth[0];
else
assert(false);
}
for (char c : oth) {
string p = ans;
p += c;
int coins = press(p);
if (coins == N) {
return p;
}
}
assert(false);
return "";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |