이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |