제출 #95577

#제출 시각아이디문제언어결과실행 시간메모리
95577rocketninja7콤보 (IOI18_combo)C++14
30 / 100
70 ms588 KiB
#include "combo.h" std::string guess_sequence(int N) { std::string p = ""; int coinsAB = press("AB"); char buttons[3]; std::string S = ""; if(coinsAB>=1){ int coinsA=press("A"); if(coinsA==1){ S+='A'; buttons[0]='B'; buttons[1]='X'; buttons[2]='Y'; } else{ S+='B'; buttons[0]='A'; buttons[1]='X'; buttons[2]='Y'; } } else{ int coinsX=press("X"); if(coinsX==1){ S+='X'; buttons[0]='A'; buttons[1]='B'; buttons[2]='Y'; } else{ S+='Y'; buttons[0]='A'; buttons[1]='B'; buttons[2]='X'; } } while(S.length()<N){ p=S+buttons[0]; if(press(p)==p.length()){ S+=buttons[0]; } else{ p=S+buttons[1]; if(press(p)==p.length()){ S+=buttons[1]; } else{ S+=buttons[2]; } } } return S; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |     while(S.length()<N){
      |           ~~~~~~~~~~^~
combo.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         if(press(p)==p.length()){
      |            ~~~~~~~~^~~~~~~~~~~~
combo.cpp:45:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             if(press(p)==p.length()){
      |                ~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...