제출 #668087

#제출 시각아이디문제언어결과실행 시간메모리
668087finn__콤보 (IOI18_combo)C++17
5 / 100
1 ms208 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

char bin_search(string s)
{
    int j = press(s + 'A' + s + 'B');
    pair<char, char> left = (j > s.size() ? make_pair('A', 'B') : make_pair('X', 'Y'));

    j = press(s + left.first);
    if (j > s.size())
        return left.first;
    return left.second;
}

string guess_sequence(int n)
{
    string p;
    p.push_back(bin_search(""));

    vector<char> x;
    for (char c : {'A', 'B', 'X', 'Y'})
        if (c != p[0])
            x.push_back(c);

    for (size_t i = 1; i < n - 1; i++)
    {
        int j = press(p + x[0] +
                      p + x[1] + x[0] +
                      p + x[1] + x[1] +
                      p + x[1] + x[2]);

        if (j == p.size())
            p.push_back(x[2]);
        else if (j == p.size() + 1)
            p.push_back(x[0]);
        else
            p.push_back(x[1]);
    }

    p.push_back(bin_search(p));
    return p;
}

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

combo.cpp: In function 'char bin_search(std::string)':
combo.cpp:8:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     pair<char, char> left = (j > s.size() ? make_pair('A', 'B') : make_pair('X', 'Y'));
      |                              ~~^~~~~~~~~~
combo.cpp:11:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     if (j > s.size())
      |         ~~^~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     for (size_t i = 1; i < n - 1; i++)
      |                        ~~^~~~~~~
combo.cpp:33:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if (j == p.size())
      |             ~~^~~~~~~~~~~
combo.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         else if (j == p.size() + 1)
      |                  ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...