# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
290015 | Tangent | Combo (IOI18_combo) | C++17 | 0 ms | 0 KiB |
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"
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(), order_of_key()
typedef long long ll;
typedef long double dd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<dd, dd> pdd;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<dd> vdd;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<vdd> vvdd;
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;
typedef vector<vpdd> vvpdd;
typedef vector<bool> vb;
const int inf = 1 << 30;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ffor(i, a, b) for(ll i = a; i < b; i++)
#define forin(x, a) for (auto &x: a)
#define all(x) x.begin(), x.end()
#ifdef TEST
#define dbg(x) cout << #x << ": " << x << '\n';
#define dbgc(x) cout << #x << ":"; forin(a, x) { cout << " " << a; } cout << endl;
#define tassert(x) assert(x);
#else
#define dbg(x)
#define dbgc(x)
#define tassert(x)
#endif
std::string guess_sequence(int N) {
if (N == 1) {
if (guess("A")) {
return ("A");
}
if (guess("B")) {
return ("B");
}
if (guess("X")) {
return ("X");
}
return ("Y");
}
char first;
string rem;
if (guess("AB")) {
if (guess("A")) {
first = 'A';
rem = "BCD";
} else {
first = 'A';
rem = "BCD";
}
} else {
if (guess("C")) {
first = 'A';
rem = "BCD";
} else {
first = 'A';
rem = "BCD";
}
}
string res;
res += first;
while (res.size() < N) {
if (res.size() == N - 1) {
if (guess(res + rem.at(0))) {
res += rem.at(0);
} else if (guess(res + rem.at(1))) {
res += rem.at(1);
} else {
res += rem.at(2);
}
} else {
int l = guess(res + rem.at(0) + res + rem.at(1) + rem.at(0) + res + rem.at(1) + rem.at(1) + res + rem.at(1) + rem.at(2));
if (l == res.size()) {
res += rem.at(2);
} else if (l == res.size() + 1) {
res += rem.at(0);
} else {
res += rem.at(1);
}
}
}
return res;
}