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>
// author : aykhn
using namespace std;
typedef long long ll;
#define pb push_back
#define ins insert
#define mpr make_pair
#define all(v) v.begin(), v.end()
#define bpc __builtin_popcount
#define bpcll __builtin_popcountll
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define infll 0x3F3F3F3F3F3F3F3F
#define inf 0x3F3F3F3F
string guess_sequence(int N)
{
string res = "";
int x = press("AB");
if (x)
{
x = press("A");
if (x) res = "A";
else res = "B";
}
else
{
x = press("X");
if (x) res = "X";
else res = "Y";
}
if (N == 1) return res;
string temp = "ABXY";
string ch;
for (int i = 0; i < 4; i++) if (temp[i] != res[0]) ch.pb(temp[i]);
int prev = 1;
int cnt = 2;
for (int i = 1; i + 1 < N; i++)
{
string s = res;
s.pb(ch[0]);
s += res;
s.pb(ch[1]);
s.pb(ch[0]);
s += res;
s.pb(ch[1]);
s.pb(ch[1]);
s += res;
s.pb(ch[1]);
s.pb(ch[2]);
x = press(s);
cnt++;
if (x == prev) res.pb(ch[2]);
else if (x == prev + 1) res.pb(ch[0]);
else res.pb(ch[1]);
prev++;
}
res.pb(ch[0]);
x = press(res);
if (x == prev + 1) return res;
res.pop_back();
res.pb(ch[1]);
x = press(res);
if (x == prev + 1) return res;
res.pop_back();
res.pb(ch[2]);
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |