제출 #423505

#제출 시각아이디문제언어결과실행 시간메모리
423505blue콤보 (IOI18_combo)C++17
100 / 100
40 ms828 KiB
#include "combo.h" #include <iostream> #include <string> #include <vector> using namespace std; /*int press(string S) { cout << S << '\n'; int res; cin >> res; return res; }*/ string guess_sequence(int N) { string res; if(press("AB") >= 1) res = (press("A") == 1 ? "A" : "B"); else res = (press("X") == 1 ? "X" : "Y"); if(N == 1) return res; string query; int query_res; vector<string> C; for(string t: {"A", "B", "X", "Y"}) if(t != res) C.push_back(t); while(res.size() < N-1) { query.clear(); query = (res + C[0]) + (res + C[1] + C[0]) + (res + C[1] + C[1]) + (res + C[1] + C[2]); query_res = press(query); if(query_res == res.size()) res += C[2]; else if(query_res == res.size() + 1) res += C[0]; else res += C[1]; } if(press(res + C[0] + res + C[1]) == res.size()) res += C[2]; else { if(press(res + C[0]) == res.size() + 1) res += C[0]; else res += C[1]; } return res; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:29:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |     while(res.size() < N-1)
      |           ~~~~~~~~~~~^~~~~
combo.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if(query_res == res.size()) res += C[2];
      |            ~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:36:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         else if(query_res == res.size() + 1) res += C[0];
      |                 ~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:40:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     if(press(res + C[0] + res + C[1]) == res.size()) res += C[2];
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:43:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         if(press(res + C[0]) == res.size() + 1) res += C[0];
      |            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...