제출 #436417

#제출 시각아이디문제언어결과실행 시간메모리
436417stoyan_malinin콤보 (IOI18_combo)C++14
100 / 100
77 ms2604 KiB
#include <algorithm> #include <iostream> #include <vector> #include <string> #include "combo.h" #ifdef __LOCAL #include "grader.cpp" #endif // __LOCAL using namespace std; char extend(string &ans, bool isLast = false) { vector <char> options = {'A', 'B', 'X', 'Y'}; if(ans.size()!=0) options.erase(find(options.begin(), options.end(), ans[0])); cerr << "-> " << ans << '\n'; if(ans.size()==0) { if(press("AB")>=1) { if(press("A")>=1) return 'A'; return 'B'; } else { if(press("X")>=1) return 'X'; return 'Y'; } } else if(isLast==false) { int res = press(ans+options[0]+options[0]+ans+options[0]+options[1]+ans+options[0]+options[2]+ans+options[1]); if(res==ans.size()+2) return options[0]; if(res==ans.size()+1) return options[1]; if(res==ans.size()+0) return options[2]; } else { int res = press(ans+options[0]+ans+options[1]); if(res==ans.size()) return options[2]; res = press(ans+options[0]); if(res==ans.size()) return options[1]; return options[0]; } } string guess_sequence(int N) { string ans = ""; for(int i = 0;i<N-1;i++) ans += extend(ans); ans += extend(ans, true); return ans; }

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

combo.cpp: In function 'char extend(std::string&, bool)':
combo.cpp:37:15: 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(res==ans.size()+2) return options[0];
      |            ~~~^~~~~~~~~~~~~~
combo.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         if(res==ans.size()+1) return options[1];
      |            ~~~^~~~~~~~~~~~~~
combo.cpp:39:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         if(res==ans.size()+0) return options[2];
      |            ~~~^~~~~~~~~~~~~~
combo.cpp:44:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         if(res==ans.size()) return options[2];
      |            ~~~^~~~~~~~~~~~
combo.cpp:47:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         if(res==ans.size()) return options[1];
      |            ~~~^~~~~~~~~~~~
combo.cpp:15:48: warning: control reaches end of non-void function [-Wreturn-type]
   15 |     vector <char> options = {'A', 'B', 'X', 'Y'};
      |                                                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...