Submission #834183

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
8341832023-08-22 11:41:19EntityPlanttCombo (IOI18_combo)C++14
100 / 100
30 ms416 KiB
#include "combo.h"
using namespace std;
// Makes 2 calls & adds on average 2 letters
inline void checkFor(string &s, char a, char b, char c) {
int r = press(s + a + a + s + a + b + s + b + a), r2;
if (s.size() + 1 == r) {
r2 = press(s + b + b);
if (r2 == s.size() + 1) s = s + b + c;
else if (r2 == s.size()) s = s + a + c;
else s = s + b + b;
}
else if (s.size() == r) s += c;
else {
r2 = press(s + a + a);
if (r2 == s.size()) s = s + b + a;
else if (r2 == s.size() + 1) s = s + a + b;
else s = s + a + a;
}
}
inline void checkFinal(string &s, char a, char b, char c) {
if (press(s + a) > s.size()) s += a;
else if (press(s + b) > s.size()) s += b;
else s += c;
}
// Should make N+2 calls
string guess_sequence(int n) {
string s;
// Should make 2 calls
if (press("AB")) { // 1st call
if (press("A")) s = "A"; // 2nd call
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

combo.cpp: In function 'void checkFor(std::string&, char, char, char)':
combo.cpp:6:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    6 |     if (s.size() + 1 == r) {
      |         ~~~~~~~~~~~~~^~~~
combo.cpp:8:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |         if (r2 == s.size() + 1) s = s + b + c;
      |             ~~~^~~~~~~~~~~~~~~
combo.cpp:9:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |         else if (r2 == s.size()) s = s + a + c;
      |                  ~~~^~~~~~~~~~~
combo.cpp:12:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |     else if (s.size() == r) s += c;
      |              ~~~~~~~~~^~~~
combo.cpp:15:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         if (r2 == s.size()) s = s + b + a;
      |             ~~~^~~~~~~~~~~
combo.cpp:16:21: 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 (r2 == s.size() + 1) s = s + a + b;
      |                  ~~~^~~~~~~~~~~~~~~
combo.cpp: In function 'void checkFinal(std::string&, char, char, char)':
combo.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     if (press(s + a) > s.size()) s += a;
      |         ~~~~~~~~~~~~~^~~~~~~~~~
combo.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     else if (press(s + b) > s.size()) s += b;
      |              ~~~~~~~~~~~~~^~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     while (s.size() < n - 1) {
      |            ~~~~~~~~~^~~~~~~
combo.cpp:42:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |     if (s.size() < n) {
      |         ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...