제출 #1082232

#제출 시각아이디문제언어결과실행 시간메모리
1082232raphael_heuchl콤보 (IOI18_combo)C++14
100 / 100
25 ms1876 KiB
#include "combo.h" #include <iostream> #include <algorithm> std::string guess_sequence(int N) { std::string ans; if (press("AB")) ans = press("B") ? "B" : "A"; else ans = press("Y") ? "Y" : "X"; std::string s = ""; for (char c : (std::string)"ABXY") if (c != ans[0]) s += c; if (N == 1) return ans; std::string guess; while (ans.size() < N - 1) { guess = ans + s[0] + \ ans + s[1] + s[0] + \ ans + s[1] + s[1] + \ ans + s[1] + s[2]; int res = press(guess); if (res == ans.size()) ans += s[2]; else if (res == ans.size() + 1) ans += s[0]; else ans += s[1]; } for (int i = 0; i < 3; ++i) { guess = ans + s[i]; if (i == 2 || press(guess) == N) return guess; } return ""; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |     while (ans.size() < N - 1)
      |            ~~~~~~~~~~~^~~~~~~
combo.cpp:29:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |       if (res == ans.size())
      |           ~~~~^~~~~~~~~~~~~
combo.cpp:31:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |       else if (res == ans.size() + 1)
      |                ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...