제출 #1072388

#제출 시각아이디문제언어결과실행 시간메모리
1072388ivaziva콤보 (IOI18_combo)C++14
100 / 100
22 ms2080 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; std::string guess_sequence(int N) { char prvoslovo; if (press("AB")==0) { if (press("X")==1) prvoslovo='X'; else prvoslovo='Y'; } else { if (press("A")==1) prvoslovo='A'; else prvoslovo='B'; } string ans;ans.push_back(prvoslovo); for (int i=2;i<N;i++) { if (prvoslovo=='X') { int val=press(ans+"Y"+ans+"AY"+ans+"AA"+ans+"AB"); if (val==ans.size()+1) ans.push_back('Y'); else if (val==ans.size()+2) ans.push_back('A'); else ans.push_back('B'); } else if (prvoslovo=='Y') { int val=press(ans+"X"+ans+"AX"+ans+"AA"+ans+"AB"); if (val==ans.size()+1) ans.push_back('X'); else if (val==ans.size()+2) ans.push_back('A'); else ans.push_back('B'); } else if (prvoslovo=='A') { int val=press(ans+"X"+ans+"YX"+ans+"YY"+ans+"YB"); if (val==ans.size()+1) ans.push_back('X'); else if (val==ans.size()+2) ans.push_back('Y'); else ans.push_back('B'); } else { int val=press(ans+"X"+ans+"YX"+ans+"YY"+ans+"YA"); if (val==ans.size()+1) ans.push_back('X'); else if (val==ans.size()+2) ans.push_back('Y'); else ans.push_back('A'); } } if (ans.size()==N) return ans; if (prvoslovo=='X') { if (press(ans+'Y')==N) ans.push_back('Y'); else if (press(ans+'A')==N) ans.push_back('A'); else ans.push_back('B'); } else if (prvoslovo=='Y') { if (press(ans+'X')==N) ans.push_back('X'); else if (press(ans+'A')==N) ans.push_back('A'); else ans.push_back('B'); } else if (prvoslovo=='A') { if (press(ans+'X')==N) ans.push_back('X'); else if (press(ans+'Y')==N) ans.push_back('Y'); else ans.push_back('B'); } else { if (press(ans+'X')==N) ans.push_back('X'); else if (press(ans+'Y')==N) ans.push_back('Y'); else ans.push_back('A'); } return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             if (val==ans.size()+1) ans.push_back('Y');
      |                 ~~~^~~~~~~~~~~~~~
combo.cpp:26:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |             else if (val==ans.size()+2) ans.push_back('A');
      |                      ~~~^~~~~~~~~~~~~~
combo.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |             if (val==ans.size()+1) ans.push_back('X');
      |                 ~~~^~~~~~~~~~~~~~
combo.cpp:33:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |             else if (val==ans.size()+2) ans.push_back('A');
      |                      ~~~^~~~~~~~~~~~~~
combo.cpp:39:20: 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 (val==ans.size()+1) ans.push_back('X');
      |                 ~~~^~~~~~~~~~~~~~
combo.cpp:40:25: 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 (val==ans.size()+2) ans.push_back('Y');
      |                      ~~~^~~~~~~~~~~~~~
combo.cpp:46:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             if (val==ans.size()+1) ans.push_back('X');
      |                 ~~~^~~~~~~~~~~~~~
combo.cpp:47:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             else if (val==ans.size()+2) ans.push_back('Y');
      |                      ~~~^~~~~~~~~~~~~~
combo.cpp:51:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |     if (ans.size()==N) return ans;
      |         ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...