이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |