제출 #750530

#제출 시각아이디문제언어결과실행 시간메모리
750530Antonn_114콤보 (IOI18_combo)C++14
100 / 100
28 ms536 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string opt = "XYAB"; string guess_sequence(int n){ // check first char first_char; if (press("AB")){ if (press("A")){ first_char = 'A'; }else{ first_char = 'B'; } }else{ if (press("X")){ first_char = 'X'; }else{ first_char = 'Y'; } } string pref; pref += first_char; vector<string> mp; // if A is first_char -> // 0 -> XX // 1 -> XY // 2 -> XB // 3 -> YX // ... // 8 -> BB if (first_char == 'X' || first_char == 'Y') opt = "ABXY"; for (int i = 0; i < 4; i++){ for (int j = 0; j < 4; j++){ if (opt[i] == first_char || opt[j] == first_char) continue; mp.push_back(string{opt[i], opt[j]}); } } for (int i = 1; i < n - 1; i++){ string first_query = pref + mp[0] + pref + mp[1] + pref + mp[4]; int res1 = press(first_query); if (res1 == 0 + pref.length()){ pref += mp[6][0]; }else{ string second_query; if (res1 == 1 + pref.length()) second_query = pref + mp[3]; else second_query = pref + mp[0]; int res2 = press(second_query); if (res2 == 0 + pref.length()){ pref += (res1 == 1 + pref.length() ? mp[2] : mp[4]); }else if (res2 == 1 + pref.length()){ pref += (res1 == 1 + pref.length() ? mp[5] : mp[1]); }else{ pref += (res1 == 1 + pref.length() ? mp[3] : mp[0]); } i++; } } if (pref.length() == n) return pref; char last_char; int k = 0; for (int i = 0; i < 4; i++){ if (opt[i] == first_char) continue; k++; if (k == 2) last_char = opt[i]; else if (press(pref + opt[i]) > pref.length()){ last_char = opt[i]; break; } } pref += last_char; return pref; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:44:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   if (res1 == 0 + pref.length()){
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:48:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |    if (res1 == 1 + pref.length()) second_query = pref + mp[3];
      |        ~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:51:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |    if (res2 == 0 + pref.length()){
      |        ~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:52:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     pref += (res1 == 1 + pref.length() ? mp[2] : mp[4]);
      |              ~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:53:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |    }else if (res2 == 1 + pref.length()){
      |              ~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:54:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     pref += (res1 == 1 + pref.length() ? mp[5] : mp[1]);
      |              ~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:56:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     pref += (res1 == 1 + pref.length() ? mp[3] : mp[0]);
      |              ~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:61:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |  if (pref.length() == n) return pref;
      |      ~~~~~~~~~~~~~~^~~~
combo.cpp:68:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |   else if (press(pref + opt[i]) > pref.length()){
      |            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...