Submission #95580

#TimeUsernameProblemLanguageResultExecution timeMemory
95580oolimryCombo (IOI18_combo)C++14
0 / 100
1 ms204 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;
std::string guess_sequence(int N) {
  string s;
  s = "AB";
  if(press(s) >= 1){
    if(press("A") == 1) s = "A";
    else s = "B";
  }
  else{
    if(press("X") == 2) s = "X";
    else s = "Y";
  }
  vector<string> v;
  if(s != "A") v.push_back("A");
  if(s != "B") v.push_back("B");
  if(s != "X") v.push_back("X");
  if(s != "Y") v.push_back("Y");

  while(s.length() < N){
    if(s.length() == N-1){
        if(press(s + v[0]) == s.length() + 1) s += v[0];
        else if(press(s + v[1]) == s.length() + 1) s += v[1];
        else s += v[2];
        continue;
    }
    string p = "";
    p += s + v[0] + v[0];
    p += s + v[0] + v[1];
    p += s + v[1] + v[0];
    int x = press(p);
    if(x == s.length() + 2){
        string q = s + v[0] + v[0];
        int y = press(q);
        if(y == s.length() + 2) s = s + v[0] + v[0];
        else if(y == s.length() + 1) s = s + v[0] + v[1];
        else s = s + v[1] + v[0];
    }
    else if(x == s.length() + 1){
        string q = s + v[1] + v[1];
        int y = press(q);
        if(y == s.length() + 2) s = s + v[1] + v[1];
        else if(y == s.length() + 1) s = s + v[1] + v[2];
        else s = s + v[0] + v[2];
    }
    else{
        s += v[2];
    }
  }
  //cout << v[0] << " " << v[1] << " " << v[2];
  return s;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |   while(s.length() < N){
      |         ~~~~~~~~~~~^~~
combo.cpp:23:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |     if(s.length() == N-1){
      |        ~~~~~~~~~~~^~~~~~
combo.cpp:24:28: 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(press(s + v[0]) == s.length() + 1) s += v[0];
      |            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:25:33: 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(press(s + v[1]) == s.length() + 1) s += v[1];
      |                 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:34:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     if(x == s.length() + 2){
      |        ~~^~~~~~~~~~~~~~~~~
combo.cpp:37:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         if(y == s.length() + 2) s = s + v[0] + v[0];
      |            ~~^~~~~~~~~~~~~~~~~
combo.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         else if(y == s.length() + 1) s = s + v[0] + v[1];
      |                 ~~^~~~~~~~~~~~~~~~~
combo.cpp:41:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     else if(x == s.length() + 1){
      |             ~~^~~~~~~~~~~~~~~~~
combo.cpp:44:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         if(y == s.length() + 2) s = s + v[1] + v[1];
      |            ~~^~~~~~~~~~~~~~~~~
combo.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         else if(y == s.length() + 1) s = s + v[1] + v[2];
      |                 ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...