# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
477057 | Genius3435 | Combo (IOI18_combo) | C++17 | 39 ms | 288 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 "combo.h"
#include <algorithm>
#include <chrono>
#include <random>
#include <string>
#include <ctime>
using namespace std::string_literals;
const int t = std::chrono::high_resolution_clock::now().time_since_epoch().count();
inline int gen(int i) {
static std::mt19937 rng = std::mt19937(t%10000/10);
return rng() % i;
}
std::string guess_sequence(int N) {
std::string cur; cur.resize(N);
for (const char c: "ABXY") {
if (press(""s+c)) {
cur[0] = c; break;
}
}
char poss[N][3], ind[N];
for (int i = 1; i < N; ++i) {
for (int k = 0, j = 0; j < 4; ++j)
if ("ABXY"[j] != cur[0]) poss[i][k++] = "ABXY"[j];
std::random_shuffle(poss[i], poss[i]+3, gen);
ind[i] = 0, cur[i] = poss[i][0];
}
for (int known = 1; known < N; ) {
if ((known = press(cur)) == N) break;
cur[known] = poss[known][++ind[known]];
}
return cur;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |