이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;
string convert(int x)
{
if(x == 1) return "A";
else if(x == 2) return "B";
else if(x == 3) return "X";
else return "Y";
}
int candi[4];
string guess_sequence(int n)
{
int first;
string ret = "";
if(press("AB"))
{
if(press("A")) first = 1, ret = "A";
else first = 2, ret = "B";
}
else
{
if(press("X")) first = 3, ret = "X";
else first = 4, ret = "Y";
}
srand(time(NULL));
fo(i,1,4) if(i != first) candi[i] = i;
fo(i,2,n-1)
{
random_shuffle(candi+1,candi+3+1);
fo(a,1,3)
{
fo(b,1,3) if(a != b)
{
string tmp = ret + convert(candi[a]);
fo(c,1,3)
tmp = tmp + ret + convert(candi[b]) + convert(candi[c]);
int answer = press(tmp);
if(answer == i + 1) ret = ret + convert(candi[b]);
else if(answer == i) ret = ret + convert(candi[a]);
else fo(k,1,3) if(k != a && k != b) {ret = ret + convert(candi[k]); break;}
goto loop;
}
}
loop:;
}
if(n != 1)
{
random_shuffle(candi+1,candi+3+1);
string tmp = ret + convert(candi[1]) + ret + convert(candi[2]);
if(press(tmp) == n)
{
tmp = ret + convert(candi[1]);
if(press(tmp) == n) {ret = tmp; goto gg;}
ret = ret + convert(candi[2]); goto gg;
}
ret = ret + convert(candi[3]);
gg:;
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |