제출 #107249

#제출 시각아이디문제언어결과실행 시간메모리
107249wonyoung콤보 (IOI18_combo)C++14
30 / 100
95 ms660 KiB
#include <vector> #include <string> using namespace std; int press(string p); string guess_sequence(int N) { vector<char> buttons = { 'A', 'B', 'X', 'Y' }; string prefix; char first_char; int n; n = press("AB"); if (n == 2) { prefix = "AB"; buttons.erase(buttons.begin()); } else if (n == 1) { if (press("A") > 0) { prefix = "A"; buttons.erase(buttons.begin()); } else { prefix = "B"; buttons.erase(buttons.begin()+1); } } else { if (press("X") > 0) { prefix = "X"; buttons.erase(buttons.begin()+2); } else { prefix = "Y"; buttons.erase(buttons.begin()+3); } } int i; bool skip = false; while (prefix.length() < N) { for (i=0; i< 2; i++) { if (i==0 && skip) { skip = false; continue; } string query_string = ""; string s = prefix; s.push_back(buttons[i]); query_string += s; while (query_string.length() + s.length() < N * 4) { s.push_back(buttons[0]); query_string += s; } n = press(query_string); if (n > prefix.length()) { if (n < s.length()) { skip = true; } break; } } prefix.push_back(buttons[i]); for (int i=prefix.length(); i<n; i++) { prefix.push_back(buttons[0]); } } return prefix; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:48:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |     while (prefix.length() < N)
      |            ~~~~~~~~~~~~~~~~^~~
combo.cpp:60:55: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |             while (query_string.length() + s.length() < N * 4)
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
combo.cpp:66:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |             if (n > prefix.length())
      |                 ~~^~~~~~~~~~~~~~~~~
combo.cpp:68:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |                 if (n < s.length())
      |                     ~~^~~~~~~~~~~~
combo.cpp:10:10: warning: unused variable 'first_char' [-Wunused-variable]
   10 |     char first_char;
      |          ^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...