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 ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define konaqua ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define otsuaqua exit(0);
#define debug(x) cout << #x << " => " << x << "\n"
#define all(x) x.begin(), x.end()
#define sp " "
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const ll INFF = 1e18 + 5;
const ll INF = 1e10 + 5;
const int MX = 1e6 + 5;
const int MXL = 105;
const int mod = 1e9 + 7;
const double ERROR = 1e-7;
const ld pi = 3.14159265358979323846;
const int set_inf = 0x3f3f3f3f;
string b[] = {"A", "B", "X", "Y"};
int res;
vector <string> arr[3];
vector <string> c;
string ans;
int ask(string Q){
cout << Q << "\n";
int resp; cin >> resp;
return resp;
}
string getFirstButton(){
res = press("AB");
if(res >= 1){
res = press("A");
if(res == 1) return "A";
else return "B";
}
else{
res = press("X");
if(res == 1) return "X";
else return "Y";
}
}
void generateArray(){
for(int i = 0; i < 4; i++){
if(b[i] != ans){
c.push_back(b[i]);
}
}
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
arr[i].push_back(c[i] + c[j]);
}
}
// for(int i = 0; i < 3; i++){
// for(int j = 0; j < 3; j++){
// cout << arr[i][j] << sp;
// }
// cout << "\n";
// }
}
string guess_sequence(int N) {
ans = getFirstButton();
generateArray();
while(ans.size() < N && N - ans.size() > 1){
res = press(ans + arr[0][1] + ans + arr[0][2] + ans + arr[1][2]);
if(res == ans.size() + 2){
res = press(ans + arr[0][1]);
if(res == ans.size() + 2) ans += arr[0][1];
else if(res == ans.size() + 1) ans += arr[0][2];
else ans += arr[1][2];
}
else if(res == ans.size() + 1){
res = press(ans + arr[1][0]);
if(res == ans.size() + 2) ans += arr[1][0];
else if(res == ans.size() + 1) ans += arr[1][1];
else ans += arr[0][0];
}
else ans += c[2];
}
if(ans.size() < N){
res = press(ans + c[0]);
if(res == ans.size() + 1) ans += c[0];
}
if(ans.size() < N){
res = press(ans + c[1]);
if(res == ans.size() + 1) ans += c[1];
}
if(ans.size() < N){
ans += c[2];
}
return ans;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:88:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
88 | while(ans.size() < N && N - ans.size() > 1){
| ~~~~~~~~~~~^~~
combo.cpp:91:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
91 | if(res == ans.size() + 2){
| ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:94:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
94 | if(res == ans.size() + 2) ans += arr[0][1];
| ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:95:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
95 | else if(res == ans.size() + 1) ans += arr[0][2];
| ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:98:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
98 | else if(res == ans.size() + 1){
| ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:101:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
101 | if(res == ans.size() + 2) ans += arr[1][0];
| ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:102:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
102 | else if(res == ans.size() + 1) ans += arr[1][1];
| ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:108:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
108 | if(ans.size() < N){
| ~~~~~~~~~~~^~~
combo.cpp:111:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
111 | if(res == ans.size() + 1) ans += c[0];
| ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:114:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
114 | if(ans.size() < N){
| ~~~~~~~~~~~^~~
combo.cpp:117:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
117 | if(res == ans.size() + 1) ans += c[1];
| ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:120:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
120 | if(ans.size() < N){
| ~~~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |