Submission #345965

#TimeUsernameProblemLanguageResultExecution timeMemory
345965IwanttobreakfreeCombo (IOI18_combo)C++14
0 / 100
77 ms200 KiB
#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 p = "XA"; for (int i = 0; i < N-2; ++i) { p+='A'; } coins=press(p); if (coins==0){//Empieza x Y S="Y"; Y=false; } else if (coins==1){//Empieza x X y no sigue A S="X"; A=false; } else { for(int c=1;c<coins;c++){//Empieza x X y sigue A S="X"; S+=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="A"; B=false; } else if (coins==1){//Empieza x B y no sigue X S="B"; X=false; } else { for(int c=1;c<coins;c++){//Empieza x B y sigue X S="B"; S+=p[c]; } X=false; } } else {//Empieza x A y sigue B for(int c=1;c<coins;c++){ S="A"; S+=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+= 'B'; else if (X) p+= 'X'; else if (Y) p += 'Y'; } } else if (S[0]=='B'){ for (int i = 0; i < N-coins; ++i) { if (A) p += 'A'; else if (X) p += 'X'; else if (Y) p += 'Y'; } } else if (S[0]=='X'){ for (int i = 0; i < N-coins; ++i) { if (A)p += 'A'; else if (B) p += 'B'; else if (Y) p += 'Y'; } } else if (S[0]=='Y'){ for (int i = 0; i < N-coins; ++i) { if (A)p += 'A'; else if (B) p += 'B'; else if (X) p += '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+=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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...