제출 #636990

#제출 시각아이디문제언어결과실행 시간메모리
636990bonk콤보 (IOI18_combo)C++14
100 / 100
28 ms600 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int n){ char tmpc[4] = {'A', 'B', 'X', 'Y'}; vector<char>c; int fi = 0; if(press("AB")){ if(press("A")) fi = 0; else fi = 1; } else{ if(press("X")) fi = 2; else fi = 3; } for(int i = 0; i < 4; i++){ if(fi != i) c.push_back(tmpc[i]); } string ans = ""; ans += tmpc[fi]; while(ans.length() < n){ if(ans.length() + 1 == n){ if(press(ans + c[0]) == n) ans += c[0]; else if(press(ans + c[1]) == n) ans += c[1]; else ans += c[2]; break; } string s = ans + c[0]; s += ans; s += c[1]; s += c[0]; s += ans; s += c[1]; s += c[1]; s += ans; s += c[1]; s += c[2]; int cur = press(s); if(cur == ans.length()) ans += c[2]; else if(cur == ans.length() + 1) ans += c[0]; else ans += c[1]; } return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
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 |     while(ans.length() < n){
      |           ~~~~~~~~~~~~~^~~
combo.cpp:27:29: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |         if(ans.length() + 1 == n){
      |            ~~~~~~~~~~~~~~~~~^~~~
combo.cpp:40:16: 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(cur == ans.length()) ans += c[2];
      |            ~~~~^~~~~~~~~~~~~~~
combo.cpp:41:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         else if(cur == ans.length() + 1) ans += c[0];
      |                 ~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...