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 x first
#define y second
#define all(v) v.begin(), v.end()
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
mt19937 rng(time(0));
//char letters[] = {'A', 'B', 'X', 'Y'};
string buttons[] = {"A", "B", "X", "Y"};
string guess_sequence(int n) {
string p = "";
if (press("AB") >= 1) {
if (press("A") >= 1) p.push_back('A');
else p.push_back('B');
} else {
if (press("X") >= 1) p.push_back('X');
else p.push_back('Y');
}
if (n == 1) return p;
vector<string> letters;
for (string s : buttons) {
if (s[0] != p[0]) letters.push_back(s);
}
for (int i = 1; i < n - 1; i++) {
shuffle(all(letters), rng);
string curr = "";
for (int j = 0; j < 3; j++) {
curr += p + letters[0] + letters[j];
}
curr += p + letters[1];
int coins = press(curr);
if (coins == i + 1) {
p += letters[1];
} else if (coins == i) {
p += letters[2];
} else {
p += letters[0];
}
}
if (press(p + letters[0] + p + letters[1]) == n) {
if (press(p + letters[0]) == n) p += letters[0];
else p += letters[1];
} else {
p += letters[2];
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |