제출 #885787

#제출 시각아이디문제언어결과실행 시간메모리
885787sq00Combo (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

string guess_sequence(int N) {
  string buttons = "", firstBtn = "";
    if(press("A") == 1) {
        firstBtn = "A";
        buttons = "BYX";
    }
    else if(press("B") == 1) {
        firstBtn = "B";
        buttons = "AYX";
    }
    else if(press("Y") == 1) {
        firstBtn = "Y";
        buttons = "ABX";
    }
    else if(press("X") == 1) {
        firstBtn = "X";
        buttons = "ABY";
    }
    string current = firstBtn;
    while(true) {
        for(int i = 0; i < buttons.size(); i++) {
            string test = current + buttons[i];
            if(press(test) == test.size()) {
                current = test;
                break;
            }
        }
        if(current.size() == n) break;
    }
    return current;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(int i = 0; i < buttons.size(); i++) {
      |                        ~~^~~~~~~~~~~~~~~~
combo.cpp:28:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             if(press(test) == test.size()) {
      |                ~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:33:30: error: 'n' was not declared in this scope
   33 |         if(current.size() == n) break;
      |                              ^