Submission #216745

#TimeUsernameProblemLanguageResultExecution timeMemory
216745tushar_2658Combo (IOI18_combo)C++14
97 / 100
40 ms672 KiB
#include "combo.h" #include "bits/stdc++.h" using namespace std; string guess_sequence(int N) { string s; if(press("A") == 1){ s = "A"; }else if(press("B")){ s = "B"; }else if(press("X")){ s = "X"; }else { s = "Y"; } if(N == 1)return s; string ss = "ABXY"; for(int i = 0; i < 4; i++){ if(ss[i] == s[0]){ ss.erase(i, 1); break; } } string c; c += ss.back(); ss.pop_back(); for(int i = 1; i < N - 1; i++){ string q = s + ss + s + ss[0] + ss[0] + s + ss[0] + c + s + ss[1]; int n = press(q); if(n == s.size()){ s += c; }else if(n == s.size() + 2){ s += ss[0]; }else { s += ss[1]; } } if(press(s + ss[0]) == s.size() + 1){ s += ss[0]; }else if(press(s + ss[1]) == s.size() + 1){ s += ss[1]; }else { s += c; } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:10: 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(n == s.size()){
      |        ~~^~~~~~~~~~~
combo.cpp:32:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     }else if(n == s.size() + 2){
      |              ~~^~~~~~~~~~~~~~~
combo.cpp:38:23: 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(press(s + ss[0]) == s.size() + 1){
      |      ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:40:29: 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(press(s + ss[1]) == s.size() + 1){
      |            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...