제출 #745638

#제출 시각아이디문제언어결과실행 시간메모리
745638borisAngelov콤보 (IOI18_combo)C++17
100 / 100
35 ms632 KiB
#include <iostream> #include <string> #include "combo.h" using namespace std; string guess_sequence(int n) { string s = ""; string p = "XY"; char a, b, c; if (press(p) > 0) { p = "X"; if (press(p) == 1) { s = "X"; a = 'A'; b = 'B'; c = 'Y'; } else { s = "Y"; a = 'A'; b = 'B'; c = 'X'; } } else { p = "A"; if (press(p) == 1) { s = "A"; a = 'B'; b = 'X'; c = 'Y'; } else { s = "B"; a = 'A'; b = 'X'; c = 'Y'; } } for (int i = 2; i < n; ++i) { p = s + a + s + b + a + s + b + b + s + b + c; int k = press(p); if (k == s.size()) { s += c; } else if (k == s.size() + 1) { s += a; } else { s += b; } } if (s.size() != n) { p = s + a; if (press(p) == n) { s += a; return s; } p = s + b; if (press(p) == n) { s += b; return s; } s += c; return s; } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:60:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         if (k == s.size())
      |             ~~^~~~~~~~~~~
combo.cpp:64:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         else if (k == s.size() + 1)
      |                  ~~^~~~~~~~~~~~~~~
combo.cpp:74:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   74 |     if (s.size() != n)
      |         ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...