제출 #639972

#제출 시각아이디문제언어결과실행 시간메모리
639972haxorman콤보 (IOI18_combo)C++14
5 / 100
2 ms208 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string s; vector<string> letters = {"A", "B", "X", "Y"}; string guess = "AB"; int coins = press(guess); if (coins == 2) { s = "AB"; } else if (coins == 1) { guess = "A"; coins = press(guess); if (coins == 1) { s = "A"; } else { s = "B"; } } else { guess = "YAYBYX"; coins = press(guess); if (coins == 1) { s = "X"; } else { s = "Y"; } } for (int i = 0; i < 4; ++i) { if (letters[i].back() == s[0]) { letters.erase(letters.begin() + i); break; } } while (s.size() < N) { guess.clear(); guess += s + letters[0]; // YB + A // YB + BA / YB + BB / YB + BX // YBAYBBAYBBBYBBX if (s.size() < N - 1) { for (int i = 0; i < 3; ++i) { guess += s + letters[1] + letters[i]; } } else { guess += s + letters[1]; } //cout << s << ' ' << guess << "\n"; coins = press(guess); if (coins == s.size()) { s += letters[2]; } else if (s.size() == N - 1) { guess = s + letters[0]; coins = press(guess); if (coins == s.size()) { s += letters[1]; } else { s += letters[0]; } } else if (coins == s.size() + 1) { s += letters[0]; } else { s += letters[1]; } } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:45:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |  while (s.size() < N) {
      |         ~~~~~~~~~^~~
combo.cpp:52:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   52 |   if (s.size() < N - 1) {
      |       ~~~~~~~~~^~~~~~~
combo.cpp:63:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |   if (coins == s.size()) {
      |       ~~~~~~^~~~~~~~~~~
combo.cpp:66:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   66 |   else if (s.size() == N - 1) {
      |            ~~~~~~~~~^~~~~~~~
combo.cpp:70:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |    if (coins == s.size()) {
      |        ~~~~~~^~~~~~~~~~~
combo.cpp:77:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |   else if (coins == s.size() + 1) {
      |            ~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...