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;
#ifdef LOCAL
#include <debug.h>
#endif
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
Tran The Bao
CTL - Da Lat
Practising for VOI23 gold medal
*/
str guess_sequence(int N) {
str ans;
int pre = press("AB");
if (pre) {
pre = press("A");
if (pre) ans.pb('A');
else ans.pb('B');
}
else {
pre = press("X");
if (pre) ans.pb('X');
else ans.pb('Y');
}
if (N == 1) return ans;
vi c;
if (ans.front() != 'A') c.pb('A');
if (ans.front() != 'B') c.pb('B');
if (ans.front() != 'X') c.pb('X');
if (ans.front() != 'Y') c.pb('Y');
FOR(i, 2, N - 1) {
str tmp;
tmp += ans;
tmp.pb(c[0]);
tmp += ans;
tmp.pb(c[1]);
tmp.pb(c[0]);
tmp += ans;
tmp.pb(c[1]);
tmp.pb(c[1]);
tmp += ans;
tmp.pb(c[1]);
tmp.pb(c[2]);
pre = press(tmp);
if (pre == i) ans.pb(c[0]);
else if (pre == i + 1) ans.pb(c[1]);
else ans.pb(c[2]);
}
str tmp = ans;
tmp.pb(c[0]);
if (press(tmp) == N) ans = tmp;
else {
tmp._pb();
tmp.pb(c[1]);
if (press(tmp) == N) ans = tmp;
else ans.pb(c[2]);
}
return ans;
}
Compilation message (stderr)
combo.cpp: In function 'str guess_sequence(int)':
combo.cpp:25:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
25 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
| ^
combo.cpp:56:2: note: in expansion of macro 'FOR'
56 | FOR(i, 2, N - 1) {
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |