제출 #489451

#제출 시각아이디문제언어결과실행 시간메모리
489451QuantumK9콤보 (IOI18_combo)C++17
30 / 100
46 ms444 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; i++ ){
    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;
}

컴파일 시 표준 에러 (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()+1 ){ start += check[0]; }
      |          ~~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |       if ( coins == start.length()+1 ){ start += check[1]; }
      |            ~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...