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;
typedef long long ll;
string guess_sequence(int n){
string st = "";
char ct = 'A';
vector<char> cs = {'A','B','X','Y'};
for(ll i=0;i<1;i++){
string sx1 = "",sx2 = "";
sx1 += cs[0];
sx1 += cs[1];
int sc11 = press(sx1);
if(sc11>0){
sx1 = "";
sx1 += (cs[0]);
sc11 = press(sx1);
if(sc11>0){
ct = cs[0];
st += ct;
}else{
ct = cs[1];
st += ct;
}
}else{
sx1 = "";
sx1 += (cs[2]);
sc11 = press(sx1);
if(sc11>0){
ct = cs[2];
st += ct;
}else{
ct = cs[3];
st += ct;
}
}
}
if(n==1) return st;
string ans = st;
vector<char> other = {'A','B','X','Y'};
auto ite = find(other.begin(),other.end(),ct);
other.erase(ite);
for(ll i=1;i<n-1;i++){
string s1 = "",s2 = "";
s1 += (ans + other[0]);
for(ll j=0;j<3;j++){
s2 += ans;
s2 += other[1];
s2 += other[j];
}
s1 += s2;
cout<<s1<<endl;
int sc1 = press(s1);
if(sc1 == ans.size()+1){
ans += other[0];
}else if(sc1 == ans.size()+2){
ans += other[1];
}else{
ans += other[2];
}
}
for(ll i=0;i<2;i++){
string str1 = ans + other[i];
int cnttt = press(str1);
if(cnttt == n) return str1;
}
return (ans + other[2]);
// for(ll i=1;i<n-1;i++){
// string s1 = "",s2 = "";
// s1 += (ans + other[0] + ans + other[1] + other[0] + ans + other[1] + other[1] + ans + other[1] + other[2]);
// int sc1 = press(s1);
// if(sc1 == ans.size()+1){
// ans += other[0];
// }else if(sc1 == ans.size()+2){
// ans += other[1];
// }else{
// ans += other[2];
// }
// }
// for(ll i=0;i<1;i++){
// string sx1 = ans,sx2 = ans;
// sx1 += other[0];
// sx1 += ans;
// sx1 += other[1];
// int sc11 = press(sx1);
// if(sc11>0){
// sx1 = ans;
// sx1 += (other[0]);
// sc11 = press(sx1);
// if(sc11>0){
// ans += other[0];
// }else{
// ans += other[1];
// }
// }else{
// ans += other[2];
// }
// }
return ans;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:56:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | if(sc1 == ans.size()+1){
| ~~~~^~~~~~~~~~~~~~~
combo.cpp:58:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | }else if(sc1 == ans.size()+2){
| ~~~~^~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |