제출 #477818

#제출 시각아이디문제언어결과실행 시간메모리
477818chungdinh콤보 (IOI18_combo)C++14
10 / 100
71 ms476 KiB
#include "combo.h"

char lst[4] = {'A', 'B', 'X', 'Y'};

std::string guess_sequence(int N) {
    std::string res = "";

    int first;

    for (int i = 0; i < 4; i++) {
        if (press(res + lst[i]) == 1) {
            first = i;
            res = res + lst[i];
            break;
        }
    }

    for (int i = 0; i < N - 1; i++) {
        for (int j = 0; j < 4; j++) {
            if (j == first) continue;
            if (press(res + lst[j]) == res.size() + 1) {
                res = res + lst[j];
                break;
            }
        }
    }

    return res;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:21:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |             if (press(res + lst[j]) == res.size() + 1) {
      |                 ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:20:13: warning: 'first' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |             if (j == first) continue;
      |             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...