This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* Problem: IOI18_combo - Combo
* Link: https://oj.uz/problem/view/IOI18_combo
* Tags: Interactive
**/
#include "combo.h"
using namespace std;
string guess_sequence(int N) {
string a("ABXY"), s("");
if (press("AB")) {
if (press("B")) swap(a[0], a[1]);
}
else {
if (press("X"))
swap(a[0], a[2]);
else swap(a[0], a[3]);
}
s += a[0];
if (N == 1) return s;
// remaining N press() for N-1 char
// build s one by one
// cmd = AC + ADB + ADC + ADD
// AB = 0, AC = 1, AD* = 2
for (int i = 2; i < N; ++i) {
int p = press((s + a[2]) + (s + a[3] + a[1]) + (s + a[3] + a[2]) + (s + a[3] + a[3]));
s += a[p - s.size() + 1];
}
// remaining 2 press() for last char
if (press(s + a[1]) == N) s += a[1];
else if (press(s + a[2]) == N) s += a[2];
else s += a[3];
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |