Submission #728991

#TimeUsernameProblemLanguageResultExecution timeMemory
728991ToxtaqCombo (IOI18_combo)C++17
100 / 100
39 ms588 KiB
#include <bits/stdc++.h> using namespace std; int press(std::string p); std::string guess_sequence(int N){ int n = N; string res = "", s; if(press("AB")){ if(press("A")){ res += 'A'; s = "BXY"; } else{ res += 'B'; s = "AXY"; } } else{ if(press("X")){ res += 'X'; s = "ABY"; } else{ res += 'Y'; s = "ABX"; } } for(int i = 1;i < n - 1;++i){ string d = res; d += s[0]; d += res; d += s[1]; d += s[0]; d += res; d += s[1]; d += s[1]; d += res; d += s[1]; d += s[2]; int num = press(d); if(num == res.size() + 1){ res += s[0]; } else if(num == res.size() + 2){ res += s[1]; } else{ res += s[2]; } } if(res.size() == n)return res; string d = res; d += s[0]; if(press(d) == n){ return d; } d.pop_back(); d += s[1]; if(press(d) == n){ return d; } d.pop_back(); d += s[2]; return d; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:41:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if(num == res.size() + 1){
      |            ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:44:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         else if(num == res.size() + 2){
      |                 ~~~~^~~~~~~~~~~~~~~~~
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(res.size() == n)return res;
      |        ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...