# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
402746 | luisgalan | Combo (IOI18_combo) | C++14 | 77 ms | 8644 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;
#define debug(x) cerr << #x << " = " << (x) << endl
char chars[4] = {'A', 'B', 'X', 'Y'};
string guess_sequence(int N) {
string res = "";
char init;
if (press("AB")) {
init = press("A") ? 'A' : 'B';
} else {
init = press("X") ? 'X' : 'Y';
}
res += string(1, init);
if (N == 1) {
return res;
}
vector<char> others;
vector<string> others_s;
for (int i = 0; i < 4; i++) {
if (chars[i] == init) continue;
others.push_back(chars[i]);
others_s.push_back(string(1, chars[i]));
}
while (res.size() + 1 < N) {
string query = "";
query += res + others_s[0] + others_s[0];
query += res + others_s[0] + others_s[1];
query += res + others_s[0] + others_s[2];
query += res + others_s[1];
debug(query);
int delta_coins = press(query) - res.size();
// debug(delta_coins);
if (delta_coins == 2) {
res += others_s[0];
} else if (delta_coins == 1) {
res += others_s[1];
} else {
res += others_s[2];
}
// debug(res);
}
if (press(res + others_s[0] + res + others_s[1]) > res.size()) {
if (press(res + others_s[0]) > res.size()) {
res += others_s[0];
} else {
res += others_s[1];
}
} else {
res += others_s[2];
}
// debug(res);
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |