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;
#define db long double
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio\
ios_base::sync_with_stdio(0);\
cin.tie(0);\
cout.tie(0)\
string guess_sequence(int n) {
string res = "";
vector<string> v;
if(press("AB")){
if(press("A")) res = "A", v = {"B", "X", "Y"};
else res = "B", v = {"A", "X", "Y"};
}
else{
if(press("X")) res = "X", v = {"A", "B", "Y"};
else res += "Y", v = {"A", "B", "X"};
}
if(n == 1)return res;
for(int i = 1; i <= n - 2; i++){
string cur = res + v[0] + v[0] + res + v[0] + v[1] + res + v[0] + v[2] + res + v[1];
int q = press(cur);
if(q == res.size() + 2) res += v[0];
else if(q == res.size() + 1) res += v[1];
else res += v[2];
}
if(press(res + "A" + res + "B") == res.size() + 1){
if(press(res + "A") == res.size() + 1) res += "A";
else res += "B";
}
else{
if(press(res + "X") == res.size() + 1) res += "X";
else res += "Y";
}
return res;
}
/*
res + BX
res + BB
res + BY
res + X
*/
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | if(q == res.size() + 2) res += v[0];
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | else if(q == res.size() + 1) res += v[1];
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:40:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | if(press(res + "A" + res + "B") == res.size() + 1){
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:41:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | if(press(res + "A") == res.size() + 1) res += "A";
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:45:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | if(press(res + "X") == res.size() + 1) res += "X";
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |