# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
971291 | codefox | Combo (IOI18_combo) | C++14 | 25 ms | 1908 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<bits/stdc++.h>
#include "combo.h"
using namespace std;
array<char, 4> arr = {'A', 'B', 'Y', 'X'};
char unknown(string s, int j, char f)
{
string ss;
string sol;
for (int i = 0; i < j; i++)
{
ss+=s[i];
}
if (f=='A')
{
sol = ss+'B';
sol += ss+"XX";
sol += ss+"XB";
sol += ss+"XY";
int c = press(sol);
if (c==j) return 'Y';
if (c==j+1) return 'B';
else return 'X';
}
if (f=='B')
{
sol = ss+'A';
sol += ss+"XX";
sol += ss+"XA";
sol += ss+"XY";
int c = press(sol);
if (c==j) return 'Y';
if (c==j+1) return 'A';
else return 'X';
}
if (f=='Y')
{
sol = ss+'A';
sol += ss+"BX";
sol += ss+"BB";
sol += ss+"BA";
int c = press(sol);
if (c==j) return 'X';
if (c==j+1) return 'A';
else return 'B';
}
if (f=='X')
{
sol = ss+'B';
sol += ss+"AA";
sol += ss+"AB";
sol += ss+"AY";
int c = press(sol);
if (c==j) return 'Y';
if (c==j+1) return 'B';
else return 'A';
}
}
string guess_sequence(int N) {
char f = 'N';
for (int i = 0; i < 3; i++)
{
string st = "";
st += arr[i];
if (press(st))
{
f = arr[i];
break;
}
}
if (f=='N') f = 'X';
if (N==1)
{
string s = "";
s+=f;
return s;
}
string s = "";
s += f;
for (int i = 1; i < N-1; i++)
{
s += unknown(s, i, f);
}
if (f!='A' && press(s+'A')==N) return s+'A';
if (f!='B' && press(s+'B')==N) return s+'B';
if (f =='X') return s+'Y';
if (f=='Y') return s+'X';
if (press(s+'Y')==N) return s+'Y';
else return s+'X';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |