Submission #345961

# Submission time Handle Problem Language Result Execution time Memory
345961 2021-01-08T18:01:18 Z Iwanttobreakfree Combo (IOI18_combo) C++14
0 / 100
65 ms 200 KB
#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,coins;
bool A,B,X,Y;
  p = "AB";
  for (int i = 0; i < N-2; ++i) {
    p += 'B';
  }
  coins = press(p);
  if(coins==0){//Empieza x X o Y
  	string p = "XA";
  for (int i = 0; i < N-2; ++i) {
    p += 'A';
  }
  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';
  }
  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){
  	p="";
  	if (S[0]=='A'){
  		for (int i = 0; i < N-coins; ++i) {
  			if (B) p[i] = 'B';
   			else if (X) p[i] = 'X';
   			else if (Y) p[i] = 'Y';
  }
	  }
	else if (S[0]=='B'){
  		for (int i = 0; i < N-coins; ++i) {
  			if (A) 	p[i] = 'A';
   			else if (X) p[i] = 'X';
   			else if (Y) p[i] = 'Y';
  }
	  }
	else if (S[0]=='X'){
  		for (int i = 0; i < N-coins; ++i) {
  			if (A)p[i] = 'A';
   			else if (B)	p[i] = 'B';
   			else if (Y)	p[i] = 'Y';
  }
}
	else if (S[0]=='Y'){
  		for (int i = 0; i < N-coins; ++i) {
  			if (A)p[i] = 'A';
   			else if (B) p[i] = 'B';
   			else if (X) p[i] = 'X';
  }
}
if (p[coins-1]=='A') A=false;
else if(p[coins-1]=='B') B=false;
else if(p[coins-1]=='X') X=false;
else if(p[coins-1]=='Y') Y=false;
   coins=press(S+p);
   if (coins>guardado){
   	A=true;
   	B=true;
   	X=true;
   	Y=true;
   	for(int c=0;c<coins-guardado;c++){
  	S[guardado+c]=p[c];
  }
  if (S[coins-1]=='A') A=false;
else if(S[coins-1]=='B') B=false;
else if(S[coins-1]=='X') X=false;
else if(S[coins-1]=='Y') Y=false;
  guardado=coins;
   }
  }
  return S;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Wrong Answer: wrong guess.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 65 ms 200 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -