제출 #97304

#제출 시각아이디문제언어결과실행 시간메모리
97304E869120콤보 (IOI18_combo)C++14
100 / 100
41 ms596 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string G = "ABXY", I; string rev(int p1, int p2) { return I.substr(p1, 1) + I.substr(p2, 1); } string guess_sequence(int N) { // At first, you should find the 1st letter int F1 = press("AB"), fir = 0; if (F1 >= 1) { int F2 = press("A"); if (F2 == 1) fir = 0; else fir = 1; } else { int F2 = press("X"); if (F2 == 1) fir = 2; else fir = 3; } for (int i = 0; i < 4; i++) { if (i != fir) I += G[i]; } // Second, you should find 2 - (N-1)th letter string S = ""; S += G[fir]; while ((int)S.size() <= N - 2) { string query = S + rev(0, 0) + S + rev(0, 1) + S + rev(1, 2); int F3 = press(query); if (F3 >= S.size() + 2) { string query2 = S + rev(0, 0); int F4 = press(query2); if (F4 == S.size() + 2) S += rev(0, 0); else if (F4 == S.size() + 1) S += rev(0, 1); else if (F4 == S.size() + 0) S += rev(1, 2); } else if (F3 == S.size() + 1) { string query2 = S + rev(1, 0); int F4 = press(query2); if (F4 == S.size() + 2) S += rev(1, 0); else if (F4 == S.size() + 1) S += rev(1, 1); else if (F4 == S.size() + 0) S += rev(0, 2); } else { S += I[2]; } } if (S.size() == N - 1) { for (int i = 0; i < 2; i++) { string query3 = S + I.substr(i, 1); int F5 = press(query3); if (F5 == N) { S += I[i]; break; } } if (S.size() == N - 1) S += I[2]; } return S; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:31:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   if (F3 >= S.size() + 2) {
      |       ~~~^~~~~~~~~~~~~~~
combo.cpp:34:11: 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 (F4 == S.size() + 2) S += rev(0, 0);
      |        ~~~^~~~~~~~~~~~~~~
combo.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |    else if (F4 == S.size() + 1) S += rev(0, 1);
      |             ~~~^~~~~~~~~~~~~~~
combo.cpp:36:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    else if (F4 == S.size() + 0) S += rev(1, 2);
      |             ~~~^~~~~~~~~~~~~~~
combo.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   else if (F3 == S.size() + 1) {
      |            ~~~^~~~~~~~~~~~~~~
combo.cpp:41:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |    if (F4 == S.size() + 2) S += rev(1, 0);
      |        ~~~^~~~~~~~~~~~~~~
combo.cpp:42:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |    else if (F4 == S.size() + 1) S += rev(1, 1);
      |             ~~~^~~~~~~~~~~~~~~
combo.cpp:43:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |    else if (F4 == S.size() + 0) S += rev(0, 2);
      |             ~~~^~~~~~~~~~~~~~~
combo.cpp:50:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |  if (S.size() == N - 1) {
      |      ~~~~~~~~~^~~~~~~~
combo.cpp:56:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |   if (S.size() == N - 1) S += I[2];
      |       ~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...