이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define OVERRIDE4(a, b, c, d, ...) d
#define REP2(i, n) for (i32 i = 0; i < (i32)(n); ++i)
#define REP3(i, l, r) for (i32 i = (i32)(l); i < (i32)(r); ++i)
#define REP(...) OVERRIDE4(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
#define PER2(i, n) for (i32 i = (i32)(n)-1; i >= 0; --i)
#define PER3(i, l, r) for (i32 i = (i32)(r)-1; i >= (i32)(l); --i)
#define PER(...) OVERRIDE4(__VA_ARGS__, PER3, PER2)(__VA_ARGS__)
#define LEN(x) (i32)(x).size()
#define ALL(x) begin(x), end(x)
using namespace std;
using i32 = int;
using i64 = long long;
template <typename T>
using V = vector<T>;
template <typename T>
bool chmin(T &x, const T &y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template <typename T>
bool chmax(T &x, const T &y) {
if (x < y) {
x = y;
return true;
}
return false;
}
#include "combo.h"
string guess_sequence(i32 n) {
const string chs = "ABXY";
string ans;
if (press(chs.substr(0, 2)) > 0) {
if (press(chs.substr(0, 1)) > 0) {
ans.push_back(chs[0]);
} else {
ans.push_back(chs[1]);
}
} else {
if (press(chs.substr(2, 1)) > 0) {
ans.push_back(chs[2]);
} else {
ans.push_back(chs[3]);
}
}
if (n == 1) {
return ans;
}
string other;
REP(i, 4) {
if (chs[i] != ans[0]) {
other.push_back(chs[i]);
}
}
string cc(2, other[0]);
string cd = cc;
cd[1] = other[1];
string ce = cc;
ce[1] = other[2];
string d(1, other[1]);
while (LEN(ans) < n - 1) {
string ask = ans + cc + ans + cd + ans + ce + ans + d;
i32 ret = press(ask);
if (ret == LEN(ans)) {
ans.push_back(other[2]);
} else if (ret == LEN(ans) + 1) {
ans.push_back(other[1]);
} else {
ans.push_back(other[0]);
}
}
REP(i, 2) {
ans.push_back(other[i]);
if (press(ans) == n) {
return ans;
}
ans.pop_back();
}
ans.push_back(other[2]);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |