제출 #418135

#제출 시각아이디문제언어결과실행 시간메모리
418135ja_kingy콤보 (IOI18_combo)C++14
100 / 100
31 ms688 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { string ls = "ABXY"; string ans; if (N == 1) { if (press("A")) return "A"; else if (press("B")) return "B"; else if (press("X")) return "X"; else return "Y"; } if (press("AB")) { ans = press("A") ? "A" : "B"; } else { ans = press("X") ? "X" : "Y"; } ls.erase(find(ls.begin(), ls.end(), ans[0])); string p; for (int i = 1; i < N-1; ++i) { p = ans + ls[0] + ls[0] + ans + ls[0] + ls[1] + ans + ls[0] + ls[2] + ans + ls[1]; int res = press(p); if (res == ans.size() + 2) { ans.push_back(ls[0]); } else if(res == ans.size()+1) { ans.push_back(ls[1]); } else { ans.push_back(ls[2]); } } p = ans + ls[0]; if (press(p) == N) ans.push_back(ls[0]); else { p = ans + ls[1]; if (press(p) == N) ans.push_back(ls[1]); else { ans.push_back(ls[2]); } } return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:13: 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 (res == ans.size() + 2) {
      |         ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:26:19: 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(res == ans.size()+1) {
      |               ~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...