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 <iostream>
#include <vector>
#include <utility>
#include <sstream>
#include <climits>
#include <cstring>
#define ll long long
#define ld long double
using namespace std;
const ll mod = 1e9 + 7;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
void get_first_letter(string &str, string &letter)
{
if (press("AB") > 0)
{
if (press("A") > 0)
{
str.push_back('A');
}
else
{
str.push_back('B');
swap(letter[0], letter[1]);
}
}
else
{
if (press("X") > 0)
{
str.push_back('X');
swap(letter[0], letter[2]);
}
else
{
str.push_back('Y');
swap(letter[0], letter[3]);
}
}
}
void get_last_letter(string &str, string &letter)
{
if (press(str + letter[1]) == (int)str.size() + 1)
{
str.push_back(letter[1]);
}
else if (press(str + letter[2]) == (int)str.size() + 1)
{
str.push_back(letter[2]);
}
else
{
str.push_back(letter[3]);
}
}
string guess_sequence(int n)
{
string ans, letter = "ABXY";
get_first_letter(ans, letter);
for (int i = 1; i < n - 1; i++)
{
int coin = press(ans + letter[1] + ans + letter[2] + letter[1] + ans + letter[2] + letter[2] + ans + letter[2] + letter[3]);
if (coin == i)
{
ans.push_back(letter[3]);
}
else if (coin == i + 1)
{
ans.push_back(letter[1]);
}
else
{
ans.push_back(letter[2]);
}
}
if (ans.size() == n - 1)
get_last_letter(ans, letter);
return ans;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:81:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
81 | if (ans.size() == n - 1)
| ~~~~~~~~~~~^~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |