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>
using namespace std;
ostream& operator<<(ostream &out, string str) {
for(char c : str) out << c;
return out;
}
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
return out << "(" << p.first << ", " << p.second << ")";
}
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
out << "{";
for(auto it = a.begin(); it != a.end(); it = next(it))
out << (it != a.begin() ? ", " : "") << *it;
return out << "}";
}
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
cerr << a << ", ";
dump(x...);
}
#ifdef DEBUG
# define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
# define debug(...) false
#endif
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
template<class T> int size(T && a) { return a.size(); }
using LL = long long;
using PII = pair<int, int>;
mt19937 rng(2137);
int rd(int a, int b) {
return uniform_int_distribution<int>(a, b)(rng);
}
#include "combo.h"
string guess_sequence(int n) {
string guess(n, 'A');
if(press("AB")) {
if(press("A")) guess[0] = 'A';
else guess[0] = 'B';
}
else {
if(press("X")) guess[0] = 'X';
else guess[0] = 'Y';
}
auto letter_id = [&](char c) {
REP(i, 4) if("ABXY"[i] == c)
return i;
};
auto get_letter = [&](vector<bool> banned) {
int x;
do x = rd(0, 3);
while(banned[x]);
return "ABXY"[x];
};
vector<bool> used(4);
used[letter_id(guess[0])] = true;
FOR(i, 1, n - 1)
guess[i] = get_letter(used);
int cur = 1;
FOR(i, 1, n - 1) {
auto banned = used;
while(cur <= i) {
banned[letter_id(guess[i])] = true;
guess[i] = get_letter(banned);
cur = press(guess);
}
}
return guess;
}
Compilation message (stderr)
combo.cpp: In lambda function:
combo.cpp:63:2: warning: control reaches end of non-void function [-Wreturn-type]
63 | };
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |