# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
111860 | Eug1ena | 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 <bits/stdc++.h>
using namespace std;
using lint = long long;
char first;
string convert(string text){ // text by 'A', 'B', 'C'
for(int i = 0; i < text.size(); i++){
if(text[i] == 'A'){
if(first <= 'A'){
text[i] = 'B';
}else{
text[i] = 'A';
}
}else if(text[i] == 'B'){
if(first <= 'B'){
text[i] = 'X';
}else{
text[i] = 'B';
}
}else if(text[i] == 'C'){
if(first <= 'X'){
text[i] = 'Y';
}else{
text[i] = 'X';
}
}else{
assert(0);
}
}
return text;
}
string guess_sequence(int N){
if(press("AB") >= 1){
if(press("A") == 1){
first = 'A';
}else{
first = 'B';
}
}else{
if(press("X") == 1){
first = 'X';
}else{
first = 'Y';
}
}
int now = 1;
string ans(1, first);
while(now + 1 < N){
int query = press(ans + convert("AA") + ans + convert("AB") + ans + convert("BA"));
if(query == now + 2){
int query2 = press(ans + convert("AA"));
if(query2 == now + 2){
ans += convert("AA");
}else if(query2 == now + 1){
ans += convert("AB");
}else if(query2 == now){
ans += convert("BA");
}else{
assert(0);
}
now += 2;
}else if(query == now + 1){
int query2 = press(ans + convert("BB"));
if(query2 == now + 2){
ans += convert("BB");
}else if(query2 == now + 1){
ans += convert("BC");
}else if(query2 == now){
ans += convert("AC");
}else{
assert(0);
}
now += 2;
}else if(query == now){
ans += convert("C");
now++;
}else{
assert(0);
}
}
if(now + 1 == N){
if(press(ans + convert("A")) == N){
return ans + convert("A");
}else if(press(ans + convert("B")) == N){
return ans + convert("B");
}else{
return ans + convert("C");
}
}else{
return ans;
}
}