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 <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <iterator>
#include <set>
#include <map>
#include <math.h>
#include <iomanip>
#include <unordered_set>
#include "combo.h"
using namespace std;
string guess_sequence(int n) {
vector<string> moves;
string s;
int coins = press("AB");
if (coins >= 1){
if (press("A")){
s = "A";
moves = {"X", "B", "Y"};
}
else{
s = "B";
moves = {"A", "X", "Y"};
}
}
else{
if (press("X")){
s = "X";
moves = {"A", "B", "Y"};
}
else{
s = "Y";
moves = {"A", "B", "X"};
}
}
if (n == 1) return s;
while (s.size() < n - 1){
string guess = s + moves[0] + s + moves[1] + moves[0] + s + moves[1] + moves[1] + s + moves[1] + moves[2];
int coins = press(guess);
if (coins == s.size()) s += moves[2];
else if (coins == s.size() + 1) s += moves[0];
else if (coins == s.size() + 2) s += moves[1];
}
for (int i = 0; i < 2; i++){
string guess = s + moves[i];
if (press(guess) == s.size() + 1) return guess;
}
return s + moves[2];
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:45:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
45 | while (s.size() < n - 1){
| ~~~~~~~~~^~~~~~~
combo.cpp:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | if (coins == s.size()) s += moves[2];
| ~~~~~~^~~~~~~~~~~
combo.cpp:50:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | else if (coins == s.size() + 1) s += moves[0];
| ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:51:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | else if (coins == s.size() + 2) s += moves[1];
| ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:57:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | if (press(guess) == s.size() + 1) return guess;
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |