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 rall(s) s.rbegin(), s.rend()
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define s second
#define f first
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e6;
string guess_sequence(int n) {
string ans = "";
if (press("AB")) {
if (press("A")) ans = "A";
else ans = "B";
}else {
if (press("X")) ans = "X";
else ans = "Y";
}
vector<char> s, h;
if (ans != "A") s.push_back('A');
if (ans != "B") s.push_back('B');
if (ans != "X") s.push_back('X');
if (ans != "Y") s.push_back('Y');
while (sz(ans) < n) {
shuffle(all(s), rng);
if (sz(h)) {
int x = press(ans + h[0] + s[0] + ans + h[0] + s[1]);
if (x == sz(ans) + 2) {
ans += h[0];
h = {s[0], s[1]};
continue;
}
if (x == sz(ans) + 1) {
ans = ans + h[0] + s[2];
h.clear();
continue;
}
ans += h[1];
h.clear();
continue;
}
if (sz(ans) == n - 1) {
if (press(ans + s[0] + ans + s[1]) == sz(ans) + 1) {
if (press(ans + s[0]) == sz(ans) + 1) ans += s[0];
else ans += s[1];
}else ans += s[2];
break;
}
int x = press(ans + s[0] + s[0] + ans + s[0] + s[1] + ans + s[1] + s[0] + ans + s[1] + s[1]);
if (x == sz(ans)) {
ans += s[2];
continue;
}
if (x == sz(ans) + 1) {
if (press(ans + s[0]) == sz(ans)) ans = ans + s[1] + s[2];
else ans = ans + s[0] + s[2];
continue;
}
x = press(ans + s[0] + s[0]);
if (x == sz(ans)) {
ans += s[1];
h = {s[0], s[1]};
continue;
}
if (x == sz(ans) + 2) ans = ans + s[0] + s[0];
else ans = ans + s[0] + s[1];
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |