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>
#ifndef EVAL
#include "grader.cpp"
#endif
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define sz(v) int((v).size())
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
int mod = 1e9+7;
ll modulo(ll a) {
return ((a % mod) + mod) % mod;
}
ll add(ll a, ll b) {
return modulo(a + b);
}
ll mult(ll a, ll b) {
return modulo(a * b);
}
ll binpow(ll a, ll b) {
ll res = 1;
while (b) {
if (b&1) {
res = mult(res, a);
}
a = mult(a, a);
b >>= 1;
}
return res;
}
string guess_sequence(int n) {
string s = "";
vector <char> addable;
char forbidden;
string q = "AB";
int res = press(q);
if (res) {
q = "A";
res = press(q);
if (res == 0) forbidden = 'B';
else forbidden = 'A';
}
else if (res == 0) {
q = "X";
res = press(q);
if (res == 0) forbidden = 'Y';
else forbidden = 'X';
}
s += forbidden;
for (auto to : {'A', 'B', 'X', 'Y'}) {
if (to == forbidden) continue;
addable.pb(to);
}
for (int i = 1; i+1 < n; i++) {
q = s+addable[0]+addable[0]+s+addable[0]+addable[1]+s+addable[1]+addable[1];
res = press(q)-sz(s);
if (res == 0) {
s += addable[2];
}
else if (res == 1) {
q = s+addable[1]+addable[0];
res = press(q)-sz(s);
if (res == 2) s = s+addable[1]+addable[0];
else if (res == 1) s = s+addable[1]+addable[2];
else s = s+addable[0]+addable[2];
i++;
}
else if (res == 2) {
q = s+addable[0]+addable[1];
res = press(q)-sz(s);
if (res == 0) s = s+addable[1]+addable[1];
else if (res == 1) s = s+addable[0]+addable[0];
else if (res == 2) s = s+addable[0]+addable[1];
i++;
}
}
if (sz(s) != n) {
q = s+addable[0];
res = press(q)-sz(s);
if (res == 1) s += addable[0];
else {
q = s+addable[1];
res = press(q)-sz(s);
if (res == 1) s += addable[1];
else s += addable[2];
}
}
return s;
}
//~ XABYAYYBYAYYB
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |