제출 #546967

#제출 시각아이디문제언어결과실행 시간메모리
546967Trisanu_Das콤보 (IOI18_combo)C++17
100 / 100
58 ms588 KiB
#include <bits/stdc++.h> #include "combo.h" #define pb push_back using namespace std; string guess_sequence(int n){ string ans = ""; if(press("AB")){ if(press("A")) ans += "A"; else ans += "B"; }else{ if(press("X")) ans += "X"; else ans += "Y"; } vector<string> s; if(ans != "A") s.pb("A"); if(ans != "B") s.pb("B"); if(ans != "X") s.pb("X"); if(ans != "Y") s.pb("Y"); for(int i = 0; i < n - 2; i++){ int tmp = press(ans + s[0] + s[0] + ans + s[0] + s[1] + ans + s[0] + s[2] + ans + s[1]); if(tmp == ans.length()) ans += s[2]; else if(tmp == ans.length() + 1) ans += s[1]; else ans += s[0]; } if(n > 1){ if(press(ans + "A" +ans + "B") == ans.length() + 1){ if(press(ans + "A") == ans.length() + 1) ans += "A"; else ans += "B"; } else{ if(press(ans + "X") == ans.length() + 1) ans += "X"; else ans += "Y"; } } return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:23:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     if(tmp == ans.length()) ans += s[2];
      |        ~~~~^~~~~~~~~~~~~~~
combo.cpp:24:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     else if(tmp == ans.length() + 1) ans += s[1];
      |             ~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:28:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   if(press(ans + "A" +ans + "B") == ans.length() + 1){
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:29:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |    if(press(ans + "A") == ans.length() + 1) ans += "A";
      |       ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:33:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    if(press(ans + "X") == ans.length() + 1) ans += "X";
      |       ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...