# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
345435 | Iwanttobreakfree | Combo (IOI18_combo) | C++14 | 1 ms | 200 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';
Y=false;
}
else if (coins==1){//Empieza x X y no sigue A
S[0]='X';
A=false;
}
else {
for(int c=0;c<coins;c++){//Empieza x X y sigue A
S[c]=p[c];
}
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';
B=false;
}
else if (coins==1){//Empieza x B y no sigue X
S[0]='B';
X=false;
}
else {
for(int c=0;c<coins;c++){//Empieza x B y sigue X
S[c]=p[c];
}
X=false;
}
}
else {//Empieza x A y sigue B
for(int c=0;c<coins;c++){
S[c]=p[c];
}
B=false;
guardado=coins;
}
while(coins<N){
if (S[0]=='A'){
for (int i = 0; i < N-coins; ++i) {
if (B) {
S += 'B';
B=false;
}
else if (X) {
S += 'X';
X=false;
}
else if (Y) {
S += 'Y';
Y=false;
}
}
}
else if (S[0]=='B'){
for (int i = 0; i < N-coins; ++i) {
if (A) {
S += 'A';
A=false;
}
else if (X) {
S += 'X';
X=false;
}
else if (Y) {
S += 'Y';
Y=false;
}
}
}
else if (S[0]=='X'){
for (int i = 0; i < N-coins; ++i) {
if (A) {
S += 'A';
A=false;
}
else if (B) {
S += 'B';
B=false;
}
else if (Y) {
S += 'Y';
Y=false;
}
}
}
else if (S[0]=='Y'){
for (int i = 0; i < N-coins; ++i) {
if (A) {
S += 'A';
A=false;
}
else if (B) {
S += 'B';
B=false;
}
else if (X) {
S += 'X';
X=false;
}
}
}
int coins=press(S);
if (coins>guardado){
A=true;
B=true;
X=true;
Y=true;
guardado=coins;
}
}
return S;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |