Submission #489453

#TimeUsernameProblemLanguageResultExecution timeMemory
489453QuantumK9콤보 (IOI18_combo)C++17
5 / 100
1 ms200 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

string guess_sequence(int N) {

  // guess the first letter: this will take at MOST two moves
  string start = "";
  int coins = press("AB");

  if ( coins > 0 ){
    coins = press("A");
    if ( coins > 0 ){ start = "A"; }
    else{ start = "B"; }
  }
  else{
    coins = press("X");
    if ( coins > 0 ){ start = "X"; }
    else{ start = "Y"; }
  }

  // guess the succeeding letters --> current method needs two guesses / letter
  string check[3];

  int ind = 0;
  if ( "A" != start ){ check[ind] = "A"; ind++; }
  if ( "B" != start ){ check[ind] = "B"; ind++; }
  if ( "X" != start ){ check[ind] = "X"; ind++; }
  if ( "Y" != start ){ check[ind] = "Y"; ind++; }

  for ( int i = 1; i < N-1; i++ ){
    coins = press( start+check[0] + start + check[1] + check[0] + start + check[1] + check[1] + start + check[1] + check[2] );

    if ( coins == start.length() ){ start += check[2]; }
    else if ( coins == start.length()+1 ){ start += check[0]; }
    else if ( coins == start.length()+2 ){ start += check[1]; }

  }

  coins = press( start+check[0]);
  if ( coins == start.length()+1 ){ start += check[0]; }
  else{
    coins = press( start+check[1] );
    if ( coins == start.length()+1 ){ start += check[1]; }
    else{ start += check[2]; }
  }

  //cout << start << endl;

  return start;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     if ( coins == start.length() ){ start += check[2]; }
      |          ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     else if ( coins == start.length()+1 ){ start += check[0]; }
      |               ~~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:37:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     else if ( coins == start.length()+2 ){ start += check[1]; }
      |               ~~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:42:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   if ( coins == start.length()+1 ){ start += check[0]; }
      |        ~~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:45:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     if ( coins == start.length()+1 ){ start += check[1]; }
      |          ~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...