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 "combo.h"
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1,(n))
#define f first
#define s second
#define pb push_back
typedef vector<int> vi;
typedef pair<int, int> pii;
std::string guess_sequence(int n) {
string buttons = "ABXY";
string ret = "";
string ask;
ask = "AB";
int coins = press(ask);
if (coins > 0) {
ask = "A";
coins = press(ask);
if (coins > 0) ret = "A";
else ret = "B";
} else {
ask = "X";
coins = press(ask);
if (coins > 0) ret = "X";
else ret = "Y";
}
if (n == 1) return ret;
string tmp = buttons;
buttons = "";
for (char c : tmp)
if (c != ret[0])
buttons += c;
FOR(i, 1, n-2) {
ask = "";
FOR(j, 0, 2) ask += ret + buttons[0] + buttons[j];
ask += ret + buttons[1];
coins = press(ask);
if (coins == i) ret += buttons[2];
else if (coins == i+1) ret += buttons[1];
else ret += buttons[0];
}
ask = ret + buttons[0] + ret + buttons[1];
coins = press(ask);
// cout << " asked " << ask << " got: " << coins << endl;
if (coins == n-1) ret += buttons[2];
else {
ask = ret + buttons[0];
coins = press(ask);
if (coins == n) ret += buttons[0];
else ret += buttons[1];
}
//cout << "ret = " << ret << endl;
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |