# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84827 | SirCeness | Combo (IOI18_combo) | C++14 | 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 "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
string head = "";
string str = "";
str = "AB";
if (press(str)){
str = "A";
if (press(str)){
head = "A";
} else head = "B";
} else {
str = "X";
if (press(str)){
head = "X";
} else head = "Y";
}
char a, b, c;
if (head[0] == 'A'){
a = 'B';
b = 'X';
c = 'Y';
} else if (head[0] == 'B'){
a = 'A';
b = 'X';
c = 'Y';
} else if (head[0] == 'X'){
a = 'B';
b = 'A';
c = 'Y';
} else if (head[0] == 'Y'){
a = 'B';
b = 'X';
c = 'A';
}
for (int i = 0; i < N-2; i++){
str = "";
str += head;
str += a;
str += a;
str += head
str += a;
str += b;
str += head
str += a;
str += c;
str += head;
str += b;
int size = head.size();
int coins = press(str);
if (coins == size+2) head += a;
else if (coins == size+1) head += b;
else if (coins == size) head += c;
}
str = "";
str += head;
str += a;
str += head;
str += b;
if (press(str) == head.size()){
head += c;
} else {
str = head + a;
if (press(str) == head.size()) head += b;
else head += a;
}
return head;
}
/*
string p = "";
for (int i = 0; i < 4 * N; ++i) {
p += 'A';
}
int coins = press(p);
string S = "";
for (int i = 0; i < N; ++i) {
S += 'A';
}
return S;
*/