제출 #728989

#제출 시각아이디문제언어결과실행 시간메모리
728989Toxtaq콤보 (IOI18_combo)C++17
97 / 100
36 ms696 KiB
#include <bits/stdc++.h> using namespace std; int press(std::string p); std::string guess_sequence(int N){ int n = N; string res = "", s; if(press("A")){ res += 'A'; s = "BXY"; } else if(press("B")){ res += 'B'; s = "AXY"; } else if(press("X")){ res += 'X'; s = "ABY"; } else{ res += 'Y'; s = "ABX"; } for(int i = 1;i < n - 1;++i){ string d = res; d += s[0]; d += res; d += s[1]; d += s[0]; d += res; d += s[1]; d += s[1]; d += res; d += s[1]; d += s[2]; int num = press(d); if(num == res.size() + 1){ res += s[0]; } else if(num == res.size() + 2){ res += s[1]; } else{ res += s[2]; } } if(res.size() == n)return res; string d = res; d += s[0]; if(press(d) == n){ return d; } d.pop_back(); d += s[1]; if(press(d) == n){ return d; } d.pop_back(); d += s[2]; return d; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         if(num == res.size() + 1){
      |            ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:40:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         else if(num == res.size() + 2){
      |                 ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:47:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |     if(res.size() == n)return res;
      |        ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...