# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
345432 | Iwanttobreakfree | 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 <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include "combo.h"
using namespace std;
string guess_sequence(int N) {
string p;
string S;
int guardado;
bool A,B,X,Y;
p = "AB";
for (int i = 0; i < N-2; ++i) {
p += 'B';
}
int coins = press(p);
if(coins==0){//Empieza x X o Y
string p = "XA";
for (int i = 0; i < N-2; ++i) {
p += 'A';
}
int coins=press(p);
if (coins==0){//Empieza x Y
S[0]='Y';
bool Y=false;
}
else if (coins==1){//Empieza x X y no sigue A
S[0]='X';
bool A=false;
}
else {
for(int a=0;a<coins<a++){//Empieza x X y sigue A
S[a]=p[a];
}
bool A=false;
}
}
else if(coins==1){//Empieza x A o x B
p="BX";
for (int i = 0; i < N-2; ++i) {
p += 'X';
}
int coins=press(p);
if(coins==0){//Empieza x A y no sigue B
S[0]='A';
bool B=false;
}
else if (coins==1){//Empieza x B y no sigue X
S[0]='B';
bool X=false;
}
else {
for(int a=0;a<coins<a++){//Empieza x B y sigue X
S[a]=p[a];
}
bool X=false;
}
}
else {//Empieza x A y sigue B
for(int a=0;a<coins<a++){
S[a]=p[a];
}
bool B=false;
guardado=coins;
}
while(coins<N){
if (S[0]=='A'){
for (int i = 0; i < N-coins; ++i) {
if (B) S += 'B',bool B=false;
else if (X) S += 'X',bool X=false;
else if (Y) S += 'Y',bool Y=false;
}
}
else if (S[0]=='B'){
for (int i = 0; i < N-coins; ++i) {
if (A) S += 'A',bool A=false;
else if (X) S += 'X',bool X=false;
else if (Y) S += 'Y',bool Y=false;
}
}
else if (S[0]=='X'){
for (int i = 0; i < N-coins; ++i) {
if (A) S += 'A', bool A=false;
else if (B) S += 'B', bool B=false;
else if (Y) S += 'Y', bool Y=false;
}
}
else if (S[0]=='Y'){
for (int i = 0; i < N-coins; ++i) {
if (A) S += 'A', bool A=false;
else if (B) S += 'B', bool B=false;
else if (X) S += 'X', bool X=false;
}
}
int coins=press(S);
if (coins>guardado){
bool A=true;
bool B=true;
bool X=true;
bool Y=true;
}
}
return S;
}