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 gg;
// int co = 0;
// int press(string s){
// co++;
// string pre;
// int ans = 0;
// for(int i = 0 ;i<gg.size();i++){
// pre += gg[i];
// bool poss=false;
// for(int j = 0;j<s.size();j++){
// if(j + pre.size() - 1 >= s.size()) break;
// if(s.substr(j,pre.size()) == pre){
// poss=true;
// }
// }
// if(poss) {
// ans = max(ans,(int)pre.size());
// }
// }
// return ans;
// }
string guess_sequence(int N){
if(N == 3){
string s;
for(int i = 0;i<N;i++){
for(char lol :{'X','Y','A','B'}){
string tmp = s;
tmp += lol;
if(press(tmp) == (s.size()+1)){
s = tmp;
break;
}
}
}
return s;
}
if(N == 1){
char c='@';
for(char lol :{'X','Y','A'}){
string s;
s+=lol;
if(press(s) == 1){
c=lol;
break;
}
}
if(c == '@'){
c= 'B';
}
string s;
s += c;
return s;
}
char c='@';
for(char lol :{'X','Y','A'}){
string s;
s+=lol;
if(press(s) == 1){
c=lol;
break;
}
}
if(c == '@'){
c= 'B';
}
string s;
s += c;
for(int i = 1;i<N-1;i++){
string query = s;
if(c == 'A'){
query += "B";
query+=s;
query+="XB";
query+=s;
query += "XX";
query += s;
query += "XY";
int lol = press(query);
int n = s.size();
if(lol == n){
s += "Y";
}
if(lol == (n+1)){
s += "B";
}
if(lol == (n+2)){
s += "X";
}
}
if(c == 'B'){
query += "A";
query+=s;
query+="XA";
query+=s;
query += "XX";
query += s;
query += "XY";
int lol = press(query);
int n = s.size();
if(lol == n){
s += "Y";
}
if(lol == (n+1)){
s += "A";
}
if(lol == (n+2)){
s += "X";
}
}
if(c == 'X'){
query += "Y";// B
query+=s;
query+="AY";// XB
query+=s;
query += "AA";// XX
query += s;
query += "AB";// XY
int lol = press(query);
int n = s.size();
if(lol == n){
s += "B";
}
if(lol == (n+1)){
s += "Y";
}
if(lol == (n+2)){
s += "A";
}
}
if(c == 'Y'){
query += "X";
query+=s;
query+="AX";
query+=s;
query += "AA";
query += s;
query += "AB";
int lol = press(query);
int n = s.size();
if(lol == n){
s += "B";
}
if(lol == (n+1)){
s += "X";
}
if(lol == (n+2)){
s += "A";
}
}
}
string se;
for(char lol : {'X','Y','A','B'}){
if(lol == c) continue;
se+=lol;
}
for(int i =0;i<se.size()-1;i++){
char lol = se[i];
string ss=s;
ss+=lol;
if(press(ss) == N){
s = ss;
return s;
}
}
s += se.back();
return s;
}
// int main(){
// int n;
// cin >> n;
// cin >> gg;
// cout << guess_sequence(n) << endl;
// cout << co << endl;
// }
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | if(press(tmp) == (s.size()+1)){
| ~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:170:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
170 | for(int i =0;i<se.size()-1;i++){
| ~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |