제출 #220004

#제출 시각아이디문제언어결과실행 시간메모리
220004BasilhijazCombo (IOI18_combo)C++14
97 / 100
39 ms616 KiB
#include <combo.h>

using namespace std;

string guess_sequence(int N) {
    string p = "";
    string ans = "";
    string ABX = "";
    int a = press("AB");
    int b = press("AX");
    if(a && b){
        ans += 'A';
        ABX = "BXY";
    }
    else if(a && !b){
        ans += 'B';
        ABX = "AXY";
    }
    else if(!a && b){
        ans += 'X';
        ABX = "ABY";
    }
    else{
        ans += 'Y';
        ABX = "ABX";
    }
    for(int i = 0; i < N - 2; i++){
        p = "";
        p += ans;
        p += ABX[0];
        p += ans;
        p += ABX[1];
        p += ABX[1];
        p += ans;
        p += ABX[1];
        p += ABX[0];
        p += ans;
        p += ABX[1];
        p += ABX[2];
        int num = press(p);
        if(num == i + 1){
            ans += ABX[2];
        }
        else if(num == i + 2){
            ans += ABX[0];
        }
        else{
            ans += ABX[1];
        }
    }
    bool ok = 1;
    if(ans.size() == N) ok = 0;
    for(int i = 0; i < 2; i++){
        p = "";
        p += ans;
        p += ABX[i];
        if(press(p) == N && ok){
            ans += ABX[i];
            ok = 0;
            break;
        }
    }
    if(ok){
        ans += ABX[2];
    }
    return ans;
}


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

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