이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define eb emplace_back
#define PI acos(-1.0)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define BIT(x, i) (1 & ((x) >> (i)))
#define MASK(x) (1LL << (x))
#define task "tnc"
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int mo = 998244353;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using pii = pair<pair<ll, ll>, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string x[] = {"A", "B", "X", "Y"};
int N;
int ask(string d)
{
int k = press(d);
return k;
}
string ans;
string guess_sequence(int n)
{
N = n;
string d;
int k = ask("AB");
if (k > 0)
{
int d = ask("A");
if (d == 1)
{
ans += "A";
}
else
{
ans += "B";
swap(x[0], x[1]);
}
}
else
{
int d = ask("X");
if (d == 1)
{
ans += "X";
swap(x[0], x[2]);
}
else
{
ans += "Y";
swap(x[0], x[3]);
}
}
k = 1;
while (k + 2 <= n)
{
string s = ans;
s += x[1];
s += x[1];
s += ans;
s += x[1];
s += x[2];
s += ans;
s += x[2];
s += x[2];
int p = ask(s);
if (p == k)
{
ans += x[3];
k++;
}
else if (p == k + 1)
{
string s = ans;
s += x[2];
s += x[3];
int d = press(s);
if (d == k)
{
ans += x[1];
ans += x[3];
k += 2;
}
else if (d == k + 1)
{
ans += x[2];
ans += x[1];
k += 2;
}
else if (d == k + 2)
{
ans += x[2];
ans += x[3];
k += 2;
}
}
else if (p == k + 2)
{
string s = ans;
s += x[1];
s += x[2];
int d = press(s);
if (d == k)
{
ans += x[2];
ans += x[1];
k += 2;
}
else if (d == k+1)
{
ans += x[1];
ans += x[1];
k += 2;
}
else if (d == k+2)
{
ans += x[1];
ans += x[2];
k += 2;
}
}
}
if (k < n)
{
string s = ans + x[0] + ans + x[1];
int d = ask(s);
if (d == n)
{
s = ans + x[0];
if (press(s) == n)
{
return s;
}
else
{
return ans + x[1];
}
}
else
{
s = ans + x[2];
if (press(s) == n)
{
return s;
}
else
{
return ans + x[3];
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |