제출 #116214

#제출 시각아이디문제언어결과실행 시간메모리
116214zubec콤보 (IOI18_combo)C++14
100 / 100
54 ms568 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; std::string guess_sequence(int N) { string s; if (press("AB")){ if (press("A")) s += 'A'; else s += 'B'; } else { if (press("X")) s += 'X'; else s += 'Y'; } vector <char> vec; if (s[0] != 'A') vec.push_back('A'); if (s[0] != 'B') vec.push_back('B'); if (s[0] != 'X') vec.push_back('X'); if (s[0] != 'Y') vec.push_back('Y'); while(s.size() < N){ if (s.size()+1 == N){ string cur = s; cur += vec[0]; cur += s; cur += vec[1]; if (press(cur) == N){ cur = s; cur += vec[0]; if (press(cur) == N){ s += vec[0]; } else s += vec[1]; } else { s += vec[2]; } break; } string cur = s; cur += vec[0]; cur += s; cur += vec[1]; cur += vec[0]; cur += s; cur += vec[1]; cur += vec[1]; cur += s; cur += vec[1]; cur += vec[2]; int len = press(cur); if (len == s.size()){ s += vec[2]; } else if (len == s.size()+1) s += vec[0]; else s += vec[1]; } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     while(s.size() < N){
      |           ~~~~~~~~~^~~
combo.cpp:26:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |         if (s.size()+1 == N){
      |             ~~~~~~~~~~~^~~~
combo.cpp:55:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         if (len == s.size()){
      |             ~~~~^~~~~~~~~~~
combo.cpp:58:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         if (len == s.size()+1)
      |             ~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...