제출 #580493

#제출 시각아이디문제언어결과실행 시간메모리
580493Vanilla콤보 (IOI18_combo)C++17
100 / 100
42 ms588 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string ord = "ABXY"; string guess_sequence(int N) { int a1 = press("AB"); int fr = 0; if (a1 == 0) { fr = 2; int a2 = press("X"); if (!a2) fr = 3; } else if (a1 == 1) { int a2 = press("A"); if (!a2) fr = 1; } if (fr == 1) ord = "BXYA"; else if (fr == 2) ord = "XYAB"; else if (fr == 3) ord = "YABX"; string rs = ""; rs.push_back(ord[0]); if (N == 1) return rs; if (N == 2) { if (press(rs + ord[1]) == 2) rs+=ord[1]; else if (press(rs + ord[2]) == 2) rs+=ord[2]; else rs+=ord[3]; return rs; } for (int i = 1; i < N - 1; i++){ string nw = rs + ord[1] + rs + ord[2] + ord[1] + rs + ord[2] + ord[2] + rs + ord[2] + ord[3]; assert(nw.size() <= 4 * N); int now = press(nw); if (now == rs.size() + 1) { rs+=ord[1]; } else if (now == rs.size() + 2) { rs+=ord[2]; } else { rs+=ord[3]; } } if (press(rs + ord[1]) == N){ if (press(rs + ord[2] + ord[1] + rs + ord[2] + ord[2] + rs + ord[2] + ord[3]) == N) rs.push_back(ord[2]); else rs.push_back(ord[1]); } else { if (press(rs + ord[2] + ord[1] + rs + ord[2] + ord[2] + rs + ord[2] + ord[3]) == N) rs.push_back(ord[2]); else rs.push_back(ord[3]); } // cout << rs << "\n"; return rs; }

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

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:1:
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |     assert(nw.size() <= 4 * N);
      |            ~~~~~~~~~~^~~~~~~~
combo.cpp:34:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     if (now == rs.size() + 1) {
      |         ~~~~^~~~~~~~~~~~~~~~
combo.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     else if (now == rs.size() + 2) {
      |              ~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...