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;
string guess_sequence(int n) {
char ch[4] = {'A', 'B', 'X', 'Y'};
int l = 0, r = 3;
while (l < r){
int mid = (l + r) >> 1;
string tmp;
for(int i = l; i <= mid; i++)
tmp.push_back(ch[i]);
if (press(tmp) > 0)
r = mid;
else
l = mid + 1;
}
swap(ch[3], ch[l]);
string s;
s.push_back(ch[3]);
for(int i = 2; i < n; i++){
string tmp = s + ch[1] + s + ch[2] + ch[0] + s + ch[2] + ch[1] + s + ch[2] + ch[2];
s.push_back(ch[press(tmp) - i + 1]);
}
if ((int) s.size() == n)
return s;
if (press(s + ch[0]) == n)
s.push_back(ch[0]);
else if (press(s + ch[1]) == n)
s.push_back(ch[1]);
else
s.push_back(ch[2]);
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |