제출 #439590

#제출 시각아이디문제언어결과실행 시간메모리
439590mangoesry콤보 (IOI18_combo)C++14
100 / 100
42 ms724 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N){ string res,first; int first_half = press("AB"); if(first_half == 0){ int second_half = press("X"); first = second_half == 0 ? "Y" : "X"; }else{ int second_half = press("A"); first = second_half == 0 ? "B" : "A"; } res = res + first; if(N == 1){ return res; } vector<string> chr = {"A","B","X","Y"}; chr.erase(find(chr.begin(),chr.end(),first)); for(int i=1;i<N-1;i++){ string guess = res + chr[0] + chr[0] + res + chr[0] + chr[1] + res + chr[0] + chr[2] + res + chr[1]; int query = press(guess); if(query == res.size()){ res = res + chr[2]; }else if(query == res.size()+1){ res = res + chr[1]; }else{ res = res + chr[0]; } } int last0 = press(res + chr[0]); int last1 = press(res + chr[1]); if(last0 == N){ res = res + chr[0]; }else if(last1 == N){ res = res + chr[1]; }else{ res = res + chr[2]; } return res; }

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

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