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;
// Templates
// ==============================================
// Debugging
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> VLL;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<pair<int, int>> VPI;
#define pb push_back
#define ff first
#define ss second
#define loop(i, s, e) for (int i = s; i < e; ++i)
#define inp(v) for (auto& x : v) cin >> x
#define all(a) a.begin(), a.end()
#define revall(a) a.rbegin(), a.rend()
#define nl "\n"
// #define MOD 998244353
#define MOD 1000000007
#define MAXN 300002
#define INF (int) 1e9
#define INFL (ll) 1e18
#define yep cout << "YES\n"
#define nope cout << "NO\n"
// ==============================================
std::string guess_sequence(int N)
{
string s;
string st = "ABXY";
if (press("AB"))
{
if (press("A")) s += 'A';
else s += 'B';
}
else
{
if (press("X")) s += 'X';
else s += 'Y';
}
if (N == 1) return s;
loop(i, 0, 4) if (st[i] == s[0])
{
st.erase(i, 1);
break;
}
string q[4];
q[0] = string("") + st[0];
q[1] = q[2] = q[3] = string("") + st[1];
loop(i, 0, 3) q[1 + i] += st[i];
loop(j, 0, N - 2)
{
string ask;
loop(i, 0, 4) ask += s + q[i];
int rep = press(ask);
int n = s.size();
if (rep == n) s += st[2];
else if (rep == n + 1) s += st[0];
else s += st[1];
}
if (press(s + st[0]) == N) s += st[0];
else if (press(s + st[1]) == N) s += st[1];
else s += st[2];
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |