Submission #75294

#TimeUsernameProblemLanguageResultExecution timeMemory
75294gs14004Combo (IOI18_combo)C++17
100 / 100
45 ms616 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string p = ""; if(press("AB") >= 1) p = press("A") ? "A" : "B"; else p = press("X") ? "X" : "Y"; vector<char> chr = {'A', 'B', 'X', 'Y'}; chr.erase(find(chr.begin(), chr.end(), p[0])); while((int)p.size() <= N - 2){ int query = press(p + chr[0] + chr[0] + p + chr[0] + chr[1] + p + chr[1] + chr[0]); if(query == p.size()){ p.push_back(chr[2]); } else if(query == p.size() + 1){ query = press(p + chr[1] + chr[2]); if(query == p.size()) p = p + chr[0] + chr[2]; else if(query == p.size() + 1) p = p + chr[1] + chr[1]; else p = p + chr[1] + chr[2]; } else{ query = press(p + chr[0] + chr[1]); if(query == p.size()) p = p + chr[1] + chr[0]; else if(query == p.size() + 1) p = p + chr[0] + chr[0]; else p = p + chr[0] + chr[1]; } } while(p.size() != N){ if(press(p + chr[0]) == p.size() + 1) p.push_back(chr[0]); else if(press(p + chr[1]) == p.size() + 1) p.push_back(chr[1]); else p.push_back(chr[2]); } return p; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |   if(query == p.size()){
      |      ~~~~~~^~~~~~~~~~~
combo.cpp:16:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   else if(query == p.size() + 1){
      |           ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:18:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |    if(query == p.size()) p = p + chr[0] + chr[2];
      |       ~~~~~~^~~~~~~~~~~
combo.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |    else if(query == p.size() + 1) p = p + chr[1] + chr[1];
      |            ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:24:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |    if(query == p.size()) p = p + chr[1] + chr[0];
      |       ~~~~~~^~~~~~~~~~~
combo.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |    else if(query == p.size() + 1) p = p + chr[0] + chr[0];
      |            ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:29:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |  while(p.size() != N){
      |        ~~~~~~~~~^~~~
combo.cpp:30:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   if(press(p + chr[0]) == p.size() + 1) p.push_back(chr[0]);
      |      ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:31:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   else if(press(p + chr[1]) == p.size() + 1) p.push_back(chr[1]);
      |           ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...