제출 #345432

#제출 시각아이디문제언어결과실행 시간메모리
345432Iwanttobreakfree콤보 (IOI18_combo)C++14
컴파일 에러
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 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; }

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:9: warning: unused variable 'Y' [-Wunused-variable]
   26 |    bool Y=false;
      |         ^
combo.cpp:30:9: warning: unused variable 'A' [-Wunused-variable]
   30 |    bool A=false;
      |         ^
combo.cpp:33:17: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses]
   33 |    for(int a=0;a<coins<a++){//Empieza x X y sigue A
      |                ~^~~~~~
combo.cpp:33:25: warning: operation on 'a' may be undefined [-Wsequence-point]
   33 |    for(int a=0;a<coins<a++){//Empieza x X y sigue A
      |                        ~^~
combo.cpp:33:25: warning: operation on 'a' may be undefined [-Wsequence-point]
combo.cpp:33:27: error: expected ';' before ')' token
   33 |    for(int a=0;a<coins<a++){//Empieza x X y sigue A
      |                           ^
      |                           ;
combo.cpp:36:8: warning: unused variable 'A' [-Wunused-variable]
   36 |   bool A=false;
      |        ^
combo.cpp:47:9: warning: unused variable 'B' [-Wunused-variable]
   47 |    bool B=false;
      |         ^
combo.cpp:51:9: warning: unused variable 'X' [-Wunused-variable]
   51 |    bool X=false;
      |         ^
combo.cpp:54:17: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses]
   54 |    for(int a=0;a<coins<a++){//Empieza x B y sigue X
      |                ~^~~~~~
combo.cpp:54:25: warning: operation on 'a' may be undefined [-Wsequence-point]
   54 |    for(int a=0;a<coins<a++){//Empieza x B y sigue X
      |                        ~^~
combo.cpp:54:25: warning: operation on 'a' may be undefined [-Wsequence-point]
combo.cpp:54:27: error: expected ';' before ')' token
   54 |    for(int a=0;a<coins<a++){//Empieza x B y sigue X
      |                           ^
      |                           ;
combo.cpp:57:8: warning: unused variable 'X' [-Wunused-variable]
   57 |   bool X=false;
      |        ^
combo.cpp:61:17: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses]
   61 |    for(int a=0;a<coins<a++){
      |                ~^~~~~~
combo.cpp:61:25: warning: operation on 'a' may be undefined [-Wsequence-point]
   61 |    for(int a=0;a<coins<a++){
      |                        ~^~
combo.cpp:61:25: warning: operation on 'a' may be undefined [-Wsequence-point]
combo.cpp:61:27: error: expected ';' before ')' token
   61 |    for(int a=0;a<coins<a++){
      |                           ^
      |                           ;
combo.cpp:64:8: warning: unused variable 'B' [-Wunused-variable]
   64 |   bool B=false;
      |        ^
combo.cpp:70:22: error: expected primary-expression before 'bool'
   70 |      if (B) S += 'B',bool B=false;
      |                      ^~~~
combo.cpp:71:28: error: expected primary-expression before 'bool'
   71 |       else if (X) S += 'X',bool X=false;
      |                            ^~~~
combo.cpp:72:28: error: expected primary-expression before 'bool'
   72 |       else if (Y) S += 'Y',bool Y=false;
      |                            ^~~~
combo.cpp:77:22: error: expected primary-expression before 'bool'
   77 |      if (A) S += 'A',bool A=false;
      |                      ^~~~
combo.cpp:78:28: error: expected primary-expression before 'bool'
   78 |       else if (X) S += 'X',bool X=false;
      |                            ^~~~
combo.cpp:79:28: error: expected primary-expression before 'bool'
   79 |       else if (Y) S += 'Y',bool Y=false;
      |                            ^~~~
combo.cpp:84:23: error: expected primary-expression before 'bool'
   84 |      if (A) S += 'A', bool A=false;
      |                       ^~~~
combo.cpp:85:29: error: expected primary-expression before 'bool'
   85 |       else if (B) S += 'B', bool B=false;
      |                             ^~~~
combo.cpp:86:29: error: expected primary-expression before 'bool'
   86 |       else if (Y) S += 'Y', bool Y=false;
      |                             ^~~~
combo.cpp:91:23: error: expected primary-expression before 'bool'
   91 |      if (A) S += 'A', bool A=false;
      |                       ^~~~
combo.cpp:92:29: error: expected primary-expression before 'bool'
   92 |       else if (B) S += 'B', bool B=false;
      |                             ^~~~
combo.cpp:93:29: error: expected primary-expression before 'bool'
   93 |       else if (X) S += 'X', bool X=false;
      |                             ^~~~
combo.cpp:98:10: warning: unused variable 'A' [-Wunused-variable]
   98 |     bool A=true;
      |          ^
combo.cpp:99:10: warning: unused variable 'B' [-Wunused-variable]
   99 |     bool B=true;
      |          ^
combo.cpp:100:10: warning: unused variable 'X' [-Wunused-variable]
  100 |     bool X=true;
      |          ^
combo.cpp:101:10: warning: unused variable 'Y' [-Wunused-variable]
  101 |     bool Y=true;
      |          ^