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 X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;
string guess_sequence(int n)
{
string all = "ABXY";
string p;
p = "AB";
int x = press(p);
char first;
if(x>= 1)
{
p = "A";
int y = press(p);
if(y == 1) first = 'A';
else first = 'B';
}
else
{
p = "X";
int y = press(p);
if(y == 1) first = 'X';
else first = 'Y';
}
string ans; ans.pb(first);
char c1 = '-', c2 = '-', c3 = '-';
for(int i = 0; i< 4; i++)
{
if(all[i] == first) continue;
if(c1 == '-') c1 = all[i];
else if(c2 == '-') c2 = all[i];
else c3 = all[i];
}
for(int i = 1; i< n-1; i++)
{
string toask;
toask += ans;
toask += c1;
toask += ans;
toask += c2;
toask += c1;
toask += ans;
toask += c2;
toask += c2;
toask += ans;
toask += c2;
toask += c3;
int res = press(toask);
if(res == i) ans.pb(c3);
else if(res == i+1) ans.pb(c1);
else ans.pb(c2);
}
if(n> 1)
{
string toask;
toask += ans;
toask += c1;
toask += ans;
toask += c2;
int res = press(toask);
if(res == n)
{
string toask;
toask += ans+c1;
int res = press(toask);
if(res == n) ans.pb(c1);
else ans.pb(c2);
}
else ans.pb(c3);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |