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>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
random_device(rd);
mt19937 rng(rd());
const long long FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
struct custom_hash
{
template<class T>
unsigned long long operator()(T v) const
{
unsigned long long x = v;
x += FIXED_RANDOM; x += 11400714819323198485ull;
x = (x ^ (x >> 30)) * 13787848793156543929ull;
x = (x ^ (x >> 27)) * 10723151780598845931ull;
return x ^ (x >> 31);
}
};
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T, class U> using hash_table = gp_hash_table<T, U, custom_hash>;
template<class T>
void ckmin(T &a, T b)
{
a = min(a, b);
}
template<class T>
void ckmax(T &a, T b)
{
a = max(a, b);
}
long long expo(long long a, long long e, long long mod)
{
return ((e == 0) ? 1 : ((expo(a * a % mod, e >> 1, mod)) * ((e & 1) ? a : 1) % mod));
}
template<class T, class U>
T nmod(T &x, U mod)
{
if (x >= mod) x -= mod;
}
template<class T>
T gcd(T a, T b)
{
return (b ? gcd(b, a % b) : a);
}
template<class T>
T randomize(T mod)
{
return (uniform_int_distribution<T>(0, mod - 1))(rng);
}
#define y0 ___y0
#define y1 ___y1
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define fi first
#define se second
#define debug(x) cerr << #x << " = " << x << endl;
#define sz(x) ((int) (x.size()))
const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-9;
#define MAGIC 347
#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
char ch[3];
string guess_sequence(int N)
{
string ans = "";
int lol1 = press("A"), lol2 = press("B"), lol3 = press("X");
if (lol1 == 1)
{
ch[0] = 'B'; ch[1] = 'X'; ch[2] = 'Y';
ans += 'A';
}
else if (lol2 == 1)
{
ch[0] = 'A'; ch[1] = 'X'; ch[2] = 'Y';
ans += 'B';
}
else if (lol3 == 1)
{
ch[0] = 'A'; ch[1] = 'B'; ch[2] = 'Y';
ans += 'X';
}
else
{
ch[0] = 'A'; ch[1] = 'B'; ch[2] = 'X';
ans += 'Y';
}
while(ans.length() < N - 1)
{
string t = ans + ch[0] + ch[0] + ans + ch[0] + ch[1] + ans + ch[1] + ch[0];
int x = press(t);
if (x == ans.length() + 0)
{
ans += ch[2];
continue;
}
else if (x == ans.length() + 1)
{
t = ans + ch[1] + ch[2];
x = press(t);
//ac, bb, bc
if (x == ans.length() + 0)
{
ans += ch[0]; ans += ch[2];
}
else if (x == ans.length() + 1)
{
ans += ch[1]; ans += ch[1];
}
else if (x == ans.length() + 2)
{
ans += ch[1]; ans += ch[2];
}
}
else if (x == ans.length() + 2)
{
//aa, ab, ba
t = ans + ch[0] + ch[0];
x = press(t);
if (x == ans.length() + 0)
{
ans += ch[1]; ans += ch[0];
}
else if (x == ans.length() + 1)
{
ans += ch[0]; ans += ch[1];
}
else if (x == ans.length() + 2)
{
ans += ch[0]; ans += ch[0];
}
}
}
if (ans.length() == N - 1)
{
string t = ans + ch[0];
lol1 = press(t);
t = ans + ch[1];
lol2 = press(t);
if (lol1 == ans.length() + 1) ans += ch[0];
else if (lol2 == ans.length() + 1) ans += ch[1];
else ans += ch[2];
}
return ans;
}
Compilation message (stderr)
combo.cpp:11:14: warning: unnecessary parentheses in declaration of 'rd' [-Wparentheses]
11 | random_device(rd);
| ^
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:116:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
116 | while(ans.length() < N - 1)
| ~~~~~~~~~~~~~^~~~~~~
combo.cpp:120:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
120 | if (x == ans.length() + 0)
| ~~^~~~~~~~~~~~~~~~~~~
combo.cpp:125:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
125 | else if (x == ans.length() + 1)
| ~~^~~~~~~~~~~~~~~~~~~
combo.cpp:130:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
130 | if (x == ans.length() + 0)
| ~~^~~~~~~~~~~~~~~~~~~
combo.cpp:134:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
134 | else if (x == ans.length() + 1)
| ~~^~~~~~~~~~~~~~~~~~~
combo.cpp:138:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
138 | else if (x == ans.length() + 2)
| ~~^~~~~~~~~~~~~~~~~~~
combo.cpp:143:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
143 | else if (x == ans.length() + 2)
| ~~^~~~~~~~~~~~~~~~~~~
combo.cpp:148:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
148 | if (x == ans.length() + 0)
| ~~^~~~~~~~~~~~~~~~~~~
combo.cpp:152:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
152 | else if (x == ans.length() + 1)
| ~~^~~~~~~~~~~~~~~~~~~
combo.cpp:156:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
156 | else if (x == ans.length() + 2)
| ~~^~~~~~~~~~~~~~~~~~~
combo.cpp:162:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
162 | if (ans.length() == N - 1)
| ~~~~~~~~~~~~~^~~~~~~~
combo.cpp:168:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
168 | if (lol1 == ans.length() + 1) ans += ch[0];
| ~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:169:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
169 | else if (lol2 == ans.length() + 1) ans += ch[1];
| ~~~~~^~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |