제출 #466808

#제출 시각아이디문제언어결과실행 시간메모리
466808jazzup콤보 (IOI18_combo)C++14
100 / 100
43 ms544 KiB
#include "combo.h" std::string guess_sequence(int N){ std::string p = ""; p="AB"; char a[3]; int m = press(p); int c; if(m==1){ c=press("A"); if(c==1){ a[0]='B'; a[1]='X'; a[2]='Y'; p="A"; } else{ a[0]='A'; a[1]='X'; a[2]='Y'; p="B"; } } else if(m==0){ c=press("X"); if(c==1){ a[0]='A'; a[1]='B'; a[2]='Y'; p="X"; } else{ a[0]='A'; a[1]='B'; a[2]='X'; p="Y"; } } else{ a[0]='B'; a[1]='X'; a[2]='Y'; if(N==2)return p; } if(N==1)return p; std::string S; int x=p.length(); for(int i=x;i<N-1;i++){ S=p; S+=a[0]; S+=a[0]; S+=p; S+=a[0]; S+=a[1]; S+=p; S+=a[0]; S+=a[2]; S+=p; S+=a[1]; c=press(S); if(c==p.length()){ p+=a[2]; } else if(c==p.length()+1){ p+=a[1]; } else{ p+=a[0]; } } S=p; S+=a[0]; c=press(S); if(c==p.length()+1) return S; else{ S=p; S+=a[1]; c=press(S); if(c==p.length()+1) return S; else{ p+=a[2]; return p; } } }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:70:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |   if(c==p.length()){
      |      ~^~~~~~~~~~~~
combo.cpp:73:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |   else if(c==p.length()+1){
      |           ~^~~~~~~~~~~~~~
combo.cpp:87:6: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |  if(c==p.length()+1)
      |     ~^~~~~~~~~~~~~~
combo.cpp:95:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |   if(c==p.length()+1)
      |      ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...