제출 #228381

#제출 시각아이디문제언어결과실행 시간메모리
228381hhh07콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <string>
#include <algorithm>
#include "combo.h"

using namespace std;

string guess_sequence(int n){
    string curr = "";
    char x[4];
    x[0] = 'A'; x[1] = 'B'; x[2] = 'X'; x[3] = 'Y';
    while(curr.length() < n){
        if (curr.length() == n - 1){
            if (press(curr + x[0]) == n)
                return curr + x[0];
            if (press(curr + x[1]) == n)
                return curr + x[1];
            return curr + x[2];
        }
        if (curr.length() == 0){
            if (press("AB")){
                if (press('A'))
                    curr += 'A';
                else
                    curr += 'B';
            }
            else{
                if (press('X'))
                    curr += 'X';
                else
                    curr += 'Y';
            }
            for (int i = 0; i < 4; i++)
                if (curr[0] == x[i])
                    x[i] = 'Z';
            sort(x, x + 4);
        }
        else{
            string s = "";
            for (int i = 0; i < 3; i++)
                s += curr + x[0] + x[i];
            s += curr + x[1] + x[3];
            if (press(s) == 2)
                curr += x[0];
            else if (press(s) == 1)
                curr += x[1];
            else
                curr += x[2];
        }
    }
    return curr;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:12:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |     while(curr.length() < n){
      |           ~~~~~~~~~~~~~~^~~
combo.cpp:13:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |         if (curr.length() == n - 1){
      |             ~~~~~~~~~~~~~~^~~~~~~~
combo.cpp:22:27: error: could not convert ''A'' from 'char' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   22 |                 if (press('A'))
      |                           ^~~
      |                           |
      |                           char
combo.cpp:28:27: error: could not convert ''X'' from 'char' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   28 |                 if (press('X'))
      |                           ^~~
      |                           |
      |                           char