Submission #346018

#TimeUsernameProblemLanguageResultExecution timeMemory
346018IwanttobreakfreeCombo (IOI18_combo)C++14
Compilation error
0 ms0 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 imp; char S[N]; 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 p="Y"; Y=false; } else if (coins==1){//Empieza x X y no sigue A p="X"; A=false; } else { p="X"; for(int c=1;c<coins;c++){//Empieza x X y sigue A p+='A'; } 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 p="A"; B=false; } else if (coins==1){//Empieza x B y no sigue X p="B"; X=false; } else { p="B"; for(int c=1;c<coins;c++){//Empieza x B y sigue X p+='X'; } X=false; } } else {//Empieza x A y sigue B p="A"; for(int c=1;c<coins;c++){ p+='B'; } B=false; } guardado=coins; while(coins<N){ imp=""; if (p[0]=='A'){ for (int i = 0; i < N-coins; ++i) { if (B) imp+= 'B'; else if (X) imp+= 'X'; else if (Y) imp += 'Y'; } } else if (p[0]=='B'){ for (int i = 0; i < N-coins; ++i) { if (A) imp += 'A'; else if (X) imp += 'X'; else if (Y) imp += 'Y'; } } else if (p[0]=='X'){ for (int i = 0; i < N-coins; ++i) { if (A) imp += 'A'; else if (B) imp += 'B'; else if (Y) imp += 'Y'; } } else if (p[0]=='Y'){ for (int i = 0; i < N-coins; ++i) { if (A) imp += 'A'; else if (B) imp += 'B'; else if (X) imp += 'X'; } } coins=press(p+imp); if (coins>guardado){ A=true; B=true; X=true; Y=true; while (coins-guardado){ p+=imp[0]; guardado++; } } 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; } while(int a=0;a<coins;a++) S[a]=p[a]; return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:118:16: error: expected ')' before ';' token
  118 |   while(int a=0;a<coins;a++) S[a]=p[a];
      |        ~       ^
      |                )
combo.cpp:118:3: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
  118 |   while(int a=0;a<coins;a++) S[a]=p[a];
      |   ^~~~~
combo.cpp:118:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
  118 |   while(int a=0;a<coins;a++) S[a]=p[a];
      |                 ^
combo.cpp:118:13: warning: unused variable 'a' [-Wunused-variable]
  118 |   while(int a=0;a<coins;a++) S[a]=p[a];
      |             ^
combo.cpp:118:17: error: 'a' was not declared in this scope
  118 |   while(int a=0;a<coins;a++) S[a]=p[a];
      |                 ^