제출 #530346

#제출 시각아이디문제언어결과실행 시간메모리
530346DJ035콤보 (IOI18_combo)C++17
100 / 100
36 ms652 KiB
#include "combo.h" #include <vector> using namespace std; std::string guess_sequence(int N) { string S,st="ABXY"; int n=N; int p=press("AB"); char f; if(!p){ p=press("X"); if(p) S += 'X'; else S += 'Y'; } else { p=press("A"); if(p) S += 'A'; else S += 'B'; } f = S[0]; vector<char> h; for(int i=0; i<4; i++) if(st[i]!=f) h.push_back(st[i]); for(int i=1; i<n-1; i++){ string in; in += S; in += h[1]; for(int j=0; j<3; j++){ in += S; in += h[0]; in += h[j]; } p=press(in); //cout << S.size() << ' ' << p << '\n'; if(p==S.size()+2) S += h[0]; else if(p==S.size()+1) S += h[1]; else S += h[2]; } if(n==1) return S; for(int i=0; i<2; i++){ p=press(S+h[i]); if(p==n) return S+h[i]; } return S+h[2]; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:35:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     if(p==S.size()+2) S += h[0];
      |        ~^~~~~~~~~~~~
combo.cpp:36:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     else if(p==S.size()+1) S += h[1];
      |             ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...