제출 #124980

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

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     if( ans.size() == N ) return ans;
      |         ~~~~~~~~~~~^~~~
combo.cpp:26:23: 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.size() < N-1 ){
      |            ~~~~~~~~~~~^~~~~
combo.cpp:34:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if( t == ans.size() ) ans += v[2];
      |             ~~^~~~~~~~~~~~~
combo.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         else if( t == ans.size() + 1 ) ans += v[1];
      |                  ~~^~~~~~~~~~~~~~~~~
combo.cpp:36:20: 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( t == ans.size() + 2 ) ans += v[0];
      |                  ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...