제출 #826955

#제출 시각아이디문제언어결과실행 시간메모리
826955wortelworm콤보 (IOI18_combo)C++17
30 / 100
43 ms584 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { char first; int coins = press("AB"); if (coins > 0) { coins = press("A"); if (coins > 0) { first = 'A'; } else { first = 'B'; } } else { coins = press("X"); if (coins > 0) { first = 'X'; } else { first = 'Y'; } } string result = ""; result += first; string options; for (char c : "ABXY") { if (c != first) { options += c; } } for (int i = 1; i < N; i++) { for (int j = 0; j < 2; j++) { coins = press(result + options[j]); if (coins > result.size()) { // this is correct result += options[j]; } } if (result.size() == i) { result += options[2]; } } return result; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             if (coins > result.size()) {
      |                 ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:43:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |         if (result.size() == i) {
      |             ~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...