제출 #696451

#제출 시각아이디문제언어결과실행 시간메모리
696451Elvin_Fritl콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "combo.h" using namespace std; string guess_sequence(int n) { string p = ""; string s="ABXY"; for(int i=0;i<3;i++){ string p1+=s[i]; if(press(p1)==1){ p=p1; break; } } if(p.size()==0){ p+=s[3]; } string s2=""; for(int i=0;i<3;i++){ if(p[0]!=s[i]){ s2+=s[i]; } } s=s2; for(int i=1;i<n;i++){ for(int j=0;j<2;j++){ string p1=p+s[j]; if(press(p1)==p1.size()){ p=p1; break; } } int kk=i; if(p.size()==kk){ p+=s[2]; } } return p; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:7:18: error: expected initializer before '+=' token
    7 |         string p1+=s[i];
      |                  ^~
combo.cpp:8:18: error: 'p1' was not declared in this scope; did you mean 'p'?
    8 |         if(press(p1)==1){
      |                  ^~
      |                  p
combo.cpp:26:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         if(press(p1)==p1.size()){
      |            ~~~~~~~~~^~~~~~~~~~~
combo.cpp:32:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |     if(p.size()==kk){
      |        ~~~~~~~~^~~~