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"};
}
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:35:14: 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(q == res.size() + 2) res += v[0];
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:36:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | else if(q == res.size() + 1) res += v[1];
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:39:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | if(press(res + "A" + res + "B") == res.size() + 1){
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:40:29: 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.size() + 1) res += "A";
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:44:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | 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... |