제출 #219970

#제출 시각아이디문제언어결과실행 시간메모리
219970Basilhijaz콤보 (IOI18_combo)C++11
5 / 100
1 ms200 KiB
#include <combo.h>

using namespace std;
string guess_sequence(int N) {
    std::string p = "";
    string ans = "";
    string opt = "ABXY";
    int pos = 0;
    for(int i = 0; i < 4; i++){
        p += opt[i];
        if(press(p)){
            ans += p;
            pos = i;
            break;
        }
        p = "";
    }
    string Fopt = "";
    for(int i = 0; i < 4; i++){
        if(i == pos)continue;
        Fopt += opt[i];
    }
    for(int i = 0; i < N - 2; i++){
        p = "";
        p += ans; p += Fopt[0]; p += ans; p += Fopt[1]; p += Fopt[1];
        p += ans; p += Fopt[1]; p += Fopt[0]; p += ans; p += Fopt[1]; p += Fopt[2];
        if(press(p) == ans.size()){
            ans += Fopt[2];
        }
        else if(press(p) == ans.size() + 1){
            ans += Fopt[0];
        }
        else{
            ans += Fopt[1];
        }
    }
    for(int i = 0; i < 3; i++){
        p = "";
        p += ans; p += Fopt[i];
        if(press(p) == N){
            ans += Fopt[i];
            break;
        }
    }
    return ans;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         if(press(p) == ans.size()){
      |            ~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:30:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         else if(press(p) == ans.size() + 1){
      |                 ~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...