# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
971294 | codefox | Combo (IOI18_combo) | C++14 | 20 ms | 2204 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;
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';
int a = press("XA");
int b = press("YA");
if (a && b) f = 'A';
else if (a) f = 'X';
else if (b) f = 'Y';
else f = 'B';
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... |