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) {
string s;
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[0], ch[l]);
for(int t = 1; t <= 2; t++){
s.push_back(ch[0]);
for(int i = 2; i <= n; i++)
s.push_back(ch[t]);
}
int lastPress = press(s);
for(int i = 2; i <= n; i++){
if (lastPress < i){
s[i - 1] = s[i + n - 1] = ch[3];
lastPress = press(s);
} else {
s[i + n - 1] = ch[1];
int tmp = press(s);
if (tmp < lastPress)
s[i - 1] = s[i + n - 1] = ch[2];
else
lastPress = tmp;
}
}
return s.substr(0, n);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |