제출 #741753

#제출 시각아이디문제언어결과실행 시간메모리
741753MODDI콤보 (IOI18_combo)C++14
100 / 100
36 ms592 KiB
#include "combo.h" #include <bits/stdc++.h> #define pb push_back using namespace std; std::string guess_sequence(int n) { string chars = "ABXY", str = ""; char first; if(press("AB")){ if(press("A")) first = 'A'; else first = 'B'; } else{ if(press("X")) first = 'X'; else first = 'Y'; } str.pb(first); chars.erase(find(chars.begin(), chars.end(), first)); if(n == 1) return str; while(str.size() < n-1){ string t = str + chars[0]; for(auto ch : chars){ t = t + str + chars[1] + ch; } int res = press(t); if(res == str.size()){ str.pb(chars[2]); } else if(res == str.size()+1) str.pb(chars[0]); else str.pb(chars[1]); } for(int i = 0; i < 2; i++){ str.pb(chars[i]); if(press(str) == n) return str; str.pop_back(); } str.pb(chars[2]); return str; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:19:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |  while(str.size() < n-1){
      |        ~~~~~~~~~~~^~~~~
combo.cpp:25:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   if(res == str.size()){
      |      ~~~~^~~~~~~~~~~~~
combo.cpp:28:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   else if(res == str.size()+1)
      |           ~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...