# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
132013 | dvdg6566 | Combo (IOI18_combo) | C++14 | 110 ms | 552 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 q;
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]);
if (N==1){
string out = "";
for (auto i :res)out+=i;return out;
}
for (x=2;x<N;++x){
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(SZ(res) + 1 == N);
// cout<<x<<' '<<N<<' '<<SZ(res)<<'\n';
// 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];
return ret;
assert(0);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |