제출 #217798

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

using namespace std;

string guess_sequence(int N)
{
    string S;
    if (press("AB"))
    {
        if (press("A"))
            S = "A";
        else
            S = "B";
    }
    else
    {
        if (press("X"))
            S = "X";
        else
            S = "Y";
    }
    while (S.size() < N - 1)
    {
        int l;
        switch (S[0])
        {
        case 'A':
            l = press(S + "BB" + S + "BX" + S + "BY" + S + "X");
            if (l == S.size() + 2)
                S += "B";
            else if (l == S.size() + 1)
                S += "X";
            else
                S += "Y";
            break;
        case 'B':
            l = press(S + "AA" + S + "AX" + S + "AY" + S + "X");
            if (l == S.size() + 2)
                S += "A";
            else if (l == S.size() + 1)
                S += "X";
            else
                S += "Y";
            break;
        case 'X':
            l = press(S + "AA" + S + "AB" + S + "AY" + S + "B");
            if (l == S.size() + 2)
                S += "A";
            else if (l == S.size() + 1)
                S += "B";
            else
                S += "Y";
            break;
        case 'Y':
            l = press(S + "AA" + S + "AB" + S + "AX" + S + "B");
            if (l == S.size() + 2)
                S += "A";
            else if (l == S.size() + 1)
                S += "B";
            else
                S += "X";
            break;
        }
    }
    if (press(S + "A" + S + "B") == S.size())
    {
        if (press(S + "A"))
            S += "A";
        else
            S += "B";
    }
    else
    {
        if (press(S + "X"))
            S += "X";
        else
            S += "Y";
    }

    return S;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:23:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |     while (S.size() < N - 1)
      |            ~~~~~~~~~^~~~~~~
combo.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             if (l == S.size() + 2)
      |                 ~~^~~~~~~~~~~~~~~
combo.cpp:32:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |             else if (l == S.size() + 1)
      |                      ~~^~~~~~~~~~~~~~~
combo.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             if (l == S.size() + 2)
      |                 ~~^~~~~~~~~~~~~~~
combo.cpp:41:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |             else if (l == S.size() + 1)
      |                      ~~^~~~~~~~~~~~~~~
combo.cpp:48:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             if (l == S.size() + 2)
      |                 ~~^~~~~~~~~~~~~~~
combo.cpp:50:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |             else if (l == S.size() + 1)
      |                      ~~^~~~~~~~~~~~~~~
combo.cpp:57:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             if (l == S.size() + 2)
      |                 ~~^~~~~~~~~~~~~~~
combo.cpp:59:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |             else if (l == S.size() + 1)
      |                      ~~^~~~~~~~~~~~~~~
combo.cpp:66:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |     if (press(S + "A" + S + "B") == S.size())
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...