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 <string>
#include <vector>
#include <iostream>
using namespace std;
std::string guess_sequence(int N) {
string s = "";
//find first
char start='1';
if(N==1){
if(press("A")){
start='A';
}
else if(press("B")){
start='B';
}
else if(press("X")){
start='X';
}
else{
start='Y';
}
}
else{
if(press("AB")){
if(press("A")){
start='A';
}
else{
start='B';
}
}
else{
if(press("X")){
start='X';
}
else{
start='Y';
}
}
}
s.push_back(start);
vector<char> but;
if(start=='A'){
but={'B','X','Y'};
}
else if(start=='B'){
but={'A','X','Y'};
}
else if(start=='X'){
but={'A','B','Y'};
}
else{
but={'A','B','X'};
}
for(int i=1;i<N-1;i++){
string q="";
q.append(s);
q.push_back(but[0]);
q.append(s);
q.push_back(but[1]);
q.push_back(but[0]);
q.append(s);
q.push_back(but[1]);
q.push_back(but[1]);
q.append(s);
q.push_back(but[1]);
q.push_back(but[2]);
//cout<<q<<endl;
int qu=press(q);
if(qu==i+0){
s.push_back(but[2]);
}
else if(qu==i+1){
s.push_back(but[0]);
}
else{
s.push_back(but[1]);
}
//cout<<qu<<endl;
//cout<<s.back()<<endl;
}
//now get last element
if(s.size()<N){
for(int i=0;i<2;i++){
s.push_back(but[i]);
if(press(s)==N){
break;
}
s.pop_back();
}
if(s.size()<N){
s.push_back(but[2]);
}
}
//cout<<s<<endl;
return s;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:90:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
90 | if(s.size()<N){
| ~~~~~~~~^~
combo.cpp:98:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
98 | if(s.size()<N){
| ~~~~~~~~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |