# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
587977 | vilji | Combo (IOI18_combo) | C++17 | 33 ms | 528 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>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
using namespace std;
#define pb push_back
#include "combo.h"
string guess_sequence(int N) {
vector<char> btns = {'A', 'B', 'X', 'Y'};
char fst;
rep(i, 0, btns.size()) {
int c = btns[i];
if (i == 3) {
fst = c;
break;
}
string p = "";
p += c;
int coins = press(p);
if (coins != 0) {
fst = c;
break;
}
}
vector<char> oth;
if (N == 1) {
string res = "";
res += fst;
return res;
}
for (char c : btns) {
if (c != fst) oth.pb(c);
}
string ans = "";
ans += fst;
rep(i, 1, N - 1) {
string p = "";
p += ans;
p += oth[0];
p += oth[0];
p += ans;
p += oth[0];
p += oth[1];
p += ans;
p += oth[0];
p += oth[2];
p += ans;
p += oth[1];
int coins = press(p);
if (coins == i)
ans += oth[2];
else if (coins == i + 1)
ans += oth[1];
else if (coins == i + 2)
ans += oth[0];
else
assert(false);
}
for (int i = 0; i < 3; i++) {
char c = oth[i];
if (i == 2) {
string p = ans;
p += c;
return p;
}
string p = ans;
p += c;
int coins = press(p);
if (coins == N) {
return p;
}
}
assert(false);
return "";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |