Submission #107274

#TimeUsernameProblemLanguageResultExecution timeMemory
107274kyunamkCombo (IOI18_combo)C++14
0 / 100
1 ms200 KiB
#include "combo.h"
#include <vector>
#include <iostream>

using namespace std;

static int debug = false;

void append_string( string &a, string b,  int N)
{
  if ( a.length() + b.length() > N )
    return;
  a += b;
}

string guess_sequence(int N) {
  debug = true;
  string p = "";
  vector<char> b ;
  b.push_back('A');
  b.push_back('B');
  b.push_back('X');
  b.push_back('Y');
  string prefix ="";
  if ( press("AB") )
  {
  //AB
    if (press("A") ) {
      prefix = "A";
      b.erase(b.begin()+0);
    }
    else
    {
      prefix = "B";
      b.erase(b.begin()+1);
    }
  }
  else
  {
  //AB
    if (press("X") )
    {
      prefix = "X";
      b.erase(b.begin()+2);
    }
    else
    {
      prefix = "Y";
      b.erase(b.begin()+3);
    }
  }
  if(debug) cout << b[0] << b[1] << b[2] << endl;
  while ( prefix.length() < N-1 ) {
    int i = 0 ;
    int n = 0;
    string append = prefix;
    append = prefix;
    string s ="";

    append.append(1,b[1]);
    s+=append;

    append = prefix;
    append.append(1,b[2]);
    for ( i = 0 ; i < 3 ; i++) {
      s+=append;
      s.append(1,b[i]);
    }

    if(debug) cout << s << " ";
    n = press(s) ;
    if(debug) cout << n << endl;

    prefix.append(1,b[n-prefix.length()]);
    if(debug) cout << "prefix " << prefix << endl;
  }

  if ( press(prefix + b[0] + prefix + b[1]) == N ) {
    if ( press(prefix + b[0]) == N )
      prefix.append(1,b[0]);
    else
      prefix.append(1,b[1]);
  } else
  {
    prefix.append(1,b[2]);
  }
  
  if(debug) cout << prefix << endl;
  return prefix;
}

Compilation message (stderr)

combo.cpp: In function 'void append_string(std::string&, std::string, int)':
combo.cpp:11:32: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   11 |   if ( a.length() + b.length() > N )
      |        ~~~~~~~~~~~~~~~~~~~~~~~~^~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:53:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |   while ( prefix.length() < N-1 ) {
      |           ~~~~~~~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...