제출 #855744

#제출 시각아이디문제언어결과실행 시간메모리
855744IS_Rushdi콤보 (IOI18_combo)C++17
0 / 100
1 ms344 KiB
// #include <iostream>
#include "combo.h"
using namespace std;

// int press(string x){
//     return 0;
// }
string guess_sequence(int N) {
  string x = "ABXY";
  string S = ""; 
  int cost = press("AB");
  if(cost != 0){
    cost = press("A");
    if(cost == 1) S += 'A';
    else S += 'B';
  }else{
    cost = press("X");
    if(cost == 1) S += 'X';
    else S += 'Y';
  }
  if(S[0] == 'A') x = "BXY";
  else if(S[0] == 'B') x = "AXY";
  else if(S[0] == 'X') x = "ABY";
  else x = "ABX";
  for(int i = 1; i < N; i++){
    string p = "";
    for(int j = 0; j < 3; j++){
        p+=S + x[0] + x[j];
    }
    p+=S + x[1];
    cost = press(p);
    if(cost-i >= 2){
        S += x[0];
    }else if(cost-i == 1){
        S += x[1];
    }else{
        S += x[2];
    }
  }
  if(S.size() != N){
    cost = press(S+x[0]);
    if(cost == N){
        S += x[0];
    }else{
        cost = press(S+x[1]);
        if(cost == N){
            S += x[1];
        }else{
            S+=x[2];
        }
        }
    }
  return S;
}
// int main(){

// }

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:40:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |   if(S.size() != N){
      |      ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...