Submission #108515

#TimeUsernameProblemLanguageResultExecution timeMemory
108515abilCombo (IOI18_combo)C++14
100 / 100
43 ms660 KiB
#include <bits/stdc++.h>
#include "combo.h"
#define mk make_pair
#define sc second
#define fr first
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define Scan(a) scanf ("%I64d", &a)
#define scan(a) scanf ("%d", &a)

using namespace std;

const long long INF = (int)1e18 + 7;
const int N = (int)1e5 + 12;
const int mod = 1000000007;

string guess_sequence(int N){
      string s = "", s1 = "AB";
      int cur = press(s1);
      if(cur == 2){
            s = "A";
      }
      else
      if(cur == 1){
            cur = press("A");
            if(cur == 1){
                  s = "A";
            }
            else{
                  s = "B";
            }
      }
      else{
            cur = press("X");
            if(cur == 1){
                  s = "X";
            }
            else{
                  s = "Y";
            }
      }
      char ch = s[0];
      if(s.size() == N){
            return s;
      }
      else{
            if(ch == 'A'){
                  while(s.size() < N - 1){
                        string s1 = s;
                        s1.pb('B');
                        s1.pb('X');
                        s1 = s1 + s;
                        s1.pb('B');
                        s1.pb('Y');
                        s1 = s1 + s;
                        s1.pb('B');
                        s1.pb('B');
                        s1 = s1 + s;
                        s1.pb('Y');
                        cur = press(s1);
                        if(cur == s.size()){
                              s.pb('X');
                        }
                        else
                        if(cur == s.size() + 1){
                              s.pb('Y');
                        }
                        else{
                              s.pb('B');
                        }
                  }
                  string s1 = s;
                  s1.pb('X');
                  cur = press(s1);
                  if(cur == s.size() + 1){
                        s.pb('X');
                  }
                  else{
                        s1 = s;
                        s1.pb('Y');
                        cur = press(s1);
                        if(cur == s.size() + 1){
                              s.pb('Y');
                        }
                        else{
                              s.pb('B');
                        }
                  }
                  return s;
            }
            if(ch == 'B'){
                  while(s.size() < N - 1){
                        string s1 = s;
                        s1.pb('A');
                        s1.pb('X');
                        s1 = s1 + s;
                        s1.pb('A');
                        s1.pb('Y');
                        s1 = s1 + s;
                        s1.pb('A');
                        s1.pb('A');
                        s1 = s1 + s;
                        s1.pb('Y');
                        cur = press(s1);
                        if(cur == s.size()){
                              s.pb('X');
                        }
                        else
                        if(cur == s.size() + 1){
                              s.pb('Y');
                        }
                        else{
                              s.pb('A');
                        }
                  }
                  string s1 = s;
                  s1.pb('X');
                  cur = press(s1);
                  if(cur == s.size() + 1){
                        s.pb('X');
                  }
                  else{
                        s1 = s;
                        s1.pb('Y');
                        cur = press(s1);
                        if(cur == s.size() + 1){
                              s.pb('Y');
                        }
                        else{
                              s.pb('A');
                        }
                  }
                  return s;
            }
            if(ch == 'X'){
                  while(s.size() < N - 1){
                        string s1 = s;
                        s1.pb('B');
                        s1.pb('A');
                        s1 = s1 + s;
                        s1.pb('B');
                        s1.pb('Y');
                        s1 = s1 + s;
                        s1.pb('B');
                        s1.pb('B');
                        s1 = s1 + s;
                        s1.pb('Y');
                        cur = press(s1);
                        if(cur == s.size()){
                              s.pb('A');
                        }
                        else
                        if(cur == s.size() + 1){
                              s.pb('Y');
                        }
                        else{
                              s.pb('B');
                        }
                  }
                  string s1 = s;
                  s1.pb('A');
                  cur = press(s1);
                  if(cur == s.size() + 1){
                        s.pb('A');
                  }
                  else{
                        s1 = s;
                        s1.pb('Y');
                        cur = press(s1);
                        if(cur == s.size() + 1){
                              s.pb('Y');
                        }
                        else{
                              s.pb('B');
                        }
                  }
                  return s;
            }
            if(ch == 'Y'){
                  while(s.size() < N - 1){
                        string s1 = s;
                        s1.pb('B');
                        s1.pb('X');
                        s1 = s1 + s;
                        s1.pb('B');
                        s1.pb('A');
                        s1 = s1 + s;
                        s1.pb('B');
                        s1.pb('B');
                        s1 = s1 + s;
                        s1.pb('A');
                        cur = press(s1);
                        if(cur == s.size()){
                              s.pb('X');
                        }
                        else
                        if(cur == s.size() + 1){
                              s.pb('A');
                        }
                        else{
                              s.pb('B');
                        }
                  }
                  string s1 = s;
                  s1.pb('X');
                  cur = press(s1);
                  if(cur == s.size() + 1){
                        s.pb('X');
                  }
                  else{
                        s1 = s;
                        s1.pb('A');
                        cur = press(s1);
                        if(cur == s.size() + 1){
                              s.pb('A');
                        }
                        else{
                              s.pb('B');
                        }
                  }
                  return s;
            }
      }

}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:44:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |       if(s.size() == N){
      |          ~~~~~~~~~^~~~
combo.cpp:49:34: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |                   while(s.size() < N - 1){
      |                         ~~~~~~~~~^~~~~~~
combo.cpp:62:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |                         if(cur == s.size()){
      |                            ~~~~^~~~~~~~~~~
combo.cpp:66:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |                         if(cur == s.size() + 1){
      |                            ~~~~^~~~~~~~~~~~~~~
combo.cpp:76:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |                   if(cur == s.size() + 1){
      |                      ~~~~^~~~~~~~~~~~~~~
combo.cpp:83:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |                         if(cur == s.size() + 1){
      |                            ~~~~^~~~~~~~~~~~~~~
combo.cpp:93:34: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   93 |                   while(s.size() < N - 1){
      |                         ~~~~~~~~~^~~~~~~
combo.cpp:106:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  106 |                         if(cur == s.size()){
      |                            ~~~~^~~~~~~~~~~
combo.cpp:110:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  110 |                         if(cur == s.size() + 1){
      |                            ~~~~^~~~~~~~~~~~~~~
combo.cpp:120:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  120 |                   if(cur == s.size() + 1){
      |                      ~~~~^~~~~~~~~~~~~~~
combo.cpp:127:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  127 |                         if(cur == s.size() + 1){
      |                            ~~~~^~~~~~~~~~~~~~~
combo.cpp:137:34: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  137 |                   while(s.size() < N - 1){
      |                         ~~~~~~~~~^~~~~~~
combo.cpp:150:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  150 |                         if(cur == s.size()){
      |                            ~~~~^~~~~~~~~~~
combo.cpp:154:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  154 |                         if(cur == s.size() + 1){
      |                            ~~~~^~~~~~~~~~~~~~~
combo.cpp:164:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  164 |                   if(cur == s.size() + 1){
      |                      ~~~~^~~~~~~~~~~~~~~
combo.cpp:171:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  171 |                         if(cur == s.size() + 1){
      |                            ~~~~^~~~~~~~~~~~~~~
combo.cpp:181:34: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  181 |                   while(s.size() < N - 1){
      |                         ~~~~~~~~~^~~~~~~
combo.cpp:194:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  194 |                         if(cur == s.size()){
      |                            ~~~~^~~~~~~~~~~
combo.cpp:198:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  198 |                         if(cur == s.size() + 1){
      |                            ~~~~^~~~~~~~~~~~~~~
combo.cpp:208:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  208 |                   if(cur == s.size() + 1){
      |                      ~~~~^~~~~~~~~~~~~~~
combo.cpp:215:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  215 |                         if(cur == s.size() + 1){
      |                            ~~~~^~~~~~~~~~~~~~~
combo.cpp:19:27: warning: control reaches end of non-void function [-Wreturn-type]
   19 |       string s = "", s1 = "AB";
      |                           ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...