#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
char ltrs[] = {'A', 'B', 'X', 'Y'};
vector<char> res;
string guess_sequence(int N) {
// cres<<N<<'\n';
int a = press("AB");
int b = press("AX");
int x;
if(a&&b)res.pb('A');
if (a&&!b)res.pb('B');
if (!a&&b)res.pb('X');
if(!a&&!b)res.pb('Y');
vector<char> V;
for (int i=0;i<4;++i)if(ltrs[i] != res[0])V.pb(ltrs[i]);
for (x=2;x<N;++x){
string q = "";
for (auto i : res)q+=i;
q += V[0];
q += V[0];
for (auto i : res)q+=i;
q += V[0];
q += V[1];
for (auto i : res)q+=i;
q += V[0];
q += V[2];
for (auto i : res)q+=i;
q += V[1];
assert(SZ(q) <= 4*N);
for (auto i : q)assert(i=='A'||i=='B'||i=='X'||i=='Y');
// cres<<q<<'\n';4
int r = press(q);
// cres<<res<<' '<<x<<'\n';
if (r == x-1){
res.pb(V[2]);
}else if (r == x+1){
res.pb(V[0]);
}else{
res.pb(V[1]);
}
}
assert(x<N);
string ret = "";
for (auto i : res)ret += i;
ret += V[0];
if (press(ret) == N)return ret;
ret = "";
for (auto i : res)ret += i;
ret += V[1];
if (press(ret) == N)return ret;
ret = "";
for (auto i : res)ret += i;
ret += V[2];
if (press(ret) == N)return ret;
assert(0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
416 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |