제출 #205674

#제출 시각아이디문제언어결과실행 시간메모리
205674SoGood콤보 (IOI18_combo)C++17
100 / 100
59 ms588 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { vector<char> v = {'A', 'B', 'X', 'Y'}; string ans=""; if (press("AB")) { if (press("A")) ans += 'A'; else ans += 'B'; } else { if (press("X")) ans += 'X'; else ans += 'Y'; } if (N==1) return ans; vector<char> vec; for (char d : v) if (d != ans[0]) vec.push_back(d); for (int i = 1; i < N - 1; ++i) { string ask = ans + vec[0] + ans + vec[1] + vec[0] + ans + vec[1] + vec[1] + ans + vec[1] + vec[2]; int res=press(ask); if (res==ans.size()) ans += vec[2]; else if (res == ans.size() + 1) ans += vec[0]; else ans += vec[1]; } for (char d : vec) { if (d==vec.back()) break; ans+=d; if (press(ans)==N) return ans; ans.pop_back(); } ans+=vec.back(); return ans; } /** abcccbd abacad */

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

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