제출 #210693

#제출 시각아이디문제언어결과실행 시간메모리
210693joylintp콤보 (IOI18_combo)C++14
100 / 100
40 ms588 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int n) { string ans; char c[3]; int tmp = press("AB"); if (tmp == 2) ans += "AB", c[0] = 'B', c[1] = 'X', c[2] = 'Y'; else if (tmp == 1) if (press("A")) ans += "A", c[0] = 'B', c[1] = 'X', c[2] = 'Y'; else ans += "B", c[0] = 'A', c[1] = 'X', c[2] = 'Y'; else if (press("X")) ans += "X", c[0] = 'A', c[1] = 'B', c[2] = 'Y'; else ans += "Y", c[0] = 'A', c[1] = 'B', c[2] = 'X'; if (ans.size() == n) return ans; while (ans.size() <= n - 2) { int tmp = press(ans + c[0] + c[1] + ans + c[0] + c[2] + ans + c[0] + c[0] + ans + c[1]); if (tmp == ans.size() + 2) ans += c[0]; else if (tmp == ans.size() + 1) ans += c[1]; else ans += c[2]; } if (press(ans + c[0]) == n) return ans + c[0]; else if (press(ans + c[1]) == n) return ans + c[1]; else return ans + c[2]; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     if (ans.size() == n)
      |         ~~~~~~~~~~~^~~~
combo.cpp:27:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     while  (ans.size() <= n - 2)
      |             ~~~~~~~~~~~^~~~~~~~
combo.cpp:30:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if (tmp == ans.size() + 2)
      |             ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:32:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         else if (tmp == ans.size() + 1)
      |                  ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...