제출 #741183

#제출 시각아이디문제언어결과실행 시간메모리
741183Charizard2021콤보 (IOI18_combo)C++17
100 / 100
30 ms576 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string cur = ""; if(press("AB") >= 1){ cur = press("A") ? "A" : "B"; } else{ cur = press("X") ? "X" : "Y"; } vector<char> characters = {'A', 'B', 'X', 'Y'}; characters.erase(find(characters.begin(), characters.end(), cur[0])); while((int)cur.size() <= N - 2){ int query = press(cur + characters[0] + characters[0] + cur + characters[0] + characters[1] + cur + characters[1] + characters[0]); if(query == cur.size()){ cur.push_back(characters[2]); } else if(query == cur.size() + 1){ query = press(cur + characters[1] + characters[2]); if(query == cur.size()) cur = cur + characters[0] + characters[2]; else if(query == cur.size() + 1) cur = cur + characters[1] + characters[1]; else cur = cur + characters[1] + characters[2]; } else{ query = press(cur + characters[0] + characters[1]); if(query == cur.size()) cur = cur + characters[1] + characters[0]; else if(query == cur.size() + 1) cur = cur + characters[0] + characters[0]; else cur = cur + characters[0] + characters[1]; } } while(cur.size() != N){ if(press(cur + characters[0]) == cur.size() + 1){ cur.push_back(characters[0]); } else if(press(cur + characters[1]) == cur.size() + 1){ cur.push_back(characters[1]); } else cur.push_back(characters[2]); } return cur; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:16:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   if(query == cur.size()){
      |      ~~~~~~^~~~~~~~~~~~~
combo.cpp:19:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   else if(query == cur.size() + 1){
      |           ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:21:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |    if(query == cur.size()) cur = cur + characters[0] + characters[2];
      |       ~~~~~~^~~~~~~~~~~~~
combo.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |    else if(query == cur.size() + 1) cur = cur + characters[1] + characters[1];
      |            ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:27:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |    if(query == cur.size()) cur = cur + characters[1] + characters[0];
      |       ~~~~~~^~~~~~~~~~~~~
combo.cpp:28:18: 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(query == cur.size() + 1) cur = cur + characters[0] + characters[0];
      |            ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:32:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |  while(cur.size() != N){
      |        ~~~~~~~~~~~^~~~
combo.cpp:33:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   if(press(cur + characters[0]) == cur.size() + 1){
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:36:38: 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(press(cur + characters[1]) == cur.size() + 1){
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...