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;
std::string guess_sequence(int N) {
string s;
string ans;
auto third_subtask = [&](int n){
string cur = "ABXY";
string s;
string ans;
ans+=cur[0];
ans+=cur[1];
if (press(ans) > 0){
ans.pop_back();
if (press(ans) == 1){
for (int j = 0;j<4;++j){
if (j != 0){
s+=cur[j];
}
}
}
else{
ans.pop_back();
ans+=cur[1];
for (int j = 0;j<4;++j){
if (j != 1){
s+=cur[j];
}
}
}
}
else{
ans.pop_back();
ans.pop_back();
ans+=cur[2];
if (press(ans) == 1){
for (int j = 0;j<4;++j){
if (j != 2){
s+=cur[j];
}
}
}
else{
ans.pop_back();
ans+=cur[3];
for (int j = 0;j<4;++j){
if (j != 3){
s+=cur[j];
}
}
}
}
if (n == 1)return ans;
//n + 1 + n + 2
for (int i = 0;i<n - 2;++i){
string p = ans;
p+=s[0];
for (int j = 0;j<3;++j){
string t = ans;
t+=s[1];
t+=s[j];
p+=t;
}
int v = press(p);
if (v == i + 2){
ans+=s[0];
}
else if (v == i + 1){
ans+=s[2];
}
else{
ans+=s[1];
}
}
for (int i = 0;i<2;++i){
ans+=s[i];
if (press(ans) == n){
return ans;
}
ans.pop_back();
}
ans+=s[2];
return ans;
};
string v = third_subtask(N);
//cout<<v<<'\n';
return v;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |