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 <bits/stdc++.h>
#include <combo.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
char cc[] = {'A', 'B', 'X', 'Y'};
bool marked[4];
string guess_sequence(int n){
char f;
if (press("AB") == 0){
if (press("X") == 0) f = 'Y';
else f = 'X';
}
else{
if (press("A") == 0) f = 'B';
else f = 'A';
}
for (ll i = 0; i < 4; i++){
if (cc[i] == f) marked[i] = 1;
}
string prefix; prefix.pb(f);
if (n == 1) return prefix;
char b = '?', x = '?';
for (ll i = 0; i < 4; i++){
if (!marked[i]){
if (b == '?') b = cc[i];
else x = cc[i];
}
}
for (ll i = 1; i < n - 1; i++){
string q;
string qb = prefix; qb.pb(b);
for (ll j = 0; j < 4; j++){
if (!marked[j]){
q += qb; q.pb(cc[j]);
}
}
q += prefix; q.pb(x);
ll cnt = press(q);
if (cnt == prefix.length() + 2) prefix.pb(b);
else if (cnt == prefix.length() + 1) prefix.pb(x);
else{
for (ll j = 0; j < 4; j++){
if ((!marked[j]) && (cc[j] != b) && (cc[j] != x)) prefix.pb(cc[j]);
}
}
}
string q = prefix; q.pb('A'); q += prefix; q.pb('B');
if (press(q) > prefix.length()){
q = prefix; q.pb('A');
if (press(q) > prefix.length()) prefix.pb('A');
else prefix.pb('B');
}
else{
q = prefix; q.pb('X');
if (press(q) > prefix.length()) prefix.pb('X');
else prefix.pb('Y');
}
return prefix;
}
Compilation message (stderr)
combo.cpp:30: warning: ignoring '#pragma 03 ' [-Wunknown-pragmas]
30 | #pragma 03
|
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:67:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | if (cnt == prefix.length() + 2) prefix.pb(b);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~
combo.cpp:68:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | else if (cnt == prefix.length() + 1) prefix.pb(x);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~
combo.cpp:76:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
76 | if (press(q) > prefix.length()){
| ~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:78:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | if (press(q) > prefix.length()) prefix.pb('A');
| ~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:83:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
83 | if (press(q) > prefix.length()) prefix.pb('X');
| ~~~~~~~~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |