제출 #390106

#제출 시각아이디문제언어결과실행 시간메모리
390106ioi콤보 (IOI18_combo)C++14
100 / 100
40 ms548 KiB
#include "combo.h"
#include<bits/stdc++.h>
using namespace std ;
 
string guess_sequence(int N) {
  string p = "";
  char a = 'A' , b = 'B' , x = 'X' , y = 'Y';
 
 
    p += a ;
    p += b;
    int coins = press(p);
    string S = "";
  if(coins){
    p = "" ;
     p += a ;
 
    coins = press(p);
    if(!coins)swap(a , b) , p = " " , p += a ;
 
 
  }
  else {
    p = "" ;
    p += x ;
 
    coins = press(p);
    if(coins)swap(a , x) ;
    else swap(y , a) , p = "" , p += a ;
 
  }
    S.push_back(a);
    int past = 1 ;
 
  while(1){
    if(S.size() == N)return S ;
    if(S.size() == N - 1){
 
        S += b ;
        if(press(S) == N)return S ;
        S.pop_back();
        S += x ;
        if(press(S) == N)return S ;
        S.pop_back();
        S += y ;
 
        return S ;
 
    }
    p = S ;
    p += b ;
    p += b ;
    p += S ;
    p += b ;
    p += x ;
    p += S ;
    p += b ;
    p += y ;
    p += S ;
    p += x ;
 
 
 
    coins = press(p);
    if(coins == past){
        S += y ;
 
    }
    else {
        if(coins - 1 == past)
            S += x ;
        else S += b ;
 
    }
    past ++ ;
 
 
  }
 
 
 
  return S;
}

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

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