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;
string guess_sequence(int n)
{
string ans;
char c[3];
int tmp = press("AB");
if (tmp == 2)
ans += "AB", c[0] = 'B', c[1] = 'X', c[2] = 'Y';
else if (tmp == 1)
if (press("A"))
ans += "A", c[0] = 'B', c[1] = 'X', c[2] = 'Y';
else
ans += "B", c[0] = 'A', c[1] = 'X', c[2] = 'Y';
else
if (press("X"))
ans += "X", c[0] = 'A', c[1] = 'B', c[2] = 'Y';
else
ans += "Y", c[0] = 'A', c[1] = 'B', c[2] = 'X';
while (ans.size() <= n - 2)
{
int tmp = press(ans + c[0] + c[1] + ans + c[0] + c[2] + ans + c[0] + c[0] + ans + c[1]);
if (tmp == ans.size() + 2)
ans += c[0];
else if (tmp == ans.size() + 1)
ans += c[1];
else
ans += c[2];
}
if (press(ans + c[0]) == n)
return ans + c[0];
else if (press(ans + c[1]) == n)
return ans + c[1];
else
return ans + c[2];
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
25 | while (ans.size() <= n - 2)
| ~~~~~~~~~~~^~~~~~~~
combo.cpp:28:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | if (tmp == ans.size() + 2)
| ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | else if (tmp == ans.size() + 1)
| ~~~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |