제출 #401698

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

using namespace std;

vector<char> abxy = {'A', 'B', 'X', 'Y'};

string guess_sequence(int n) {
    string s;
    for (int i = 0; i < 3; i++){
        string p;
        p += abxy[i];
        if (press(p) == 1){
            s = p;
            break;
        }
    }

    if (s.empty()) s = "Y";

    for (int i = 0; i < 4; i++){
        if (abxy[i] == s[0]){
            abxy.erase(abxy.begin() + i, abxy.begin() + i + 1);
            break;
        }
    }

    while (s.size() < n - 1){
        string p;
        for (int i = 0; i < 3; i++){
            p += s + abxy[0] + abxy[i];
        }
        p += s + abxy[1];

        cout << p << endl;

        int x = press(p);

        char ch;
        if (x == s.size()) ch = abxy[2]; else
        if (x == s.size() + 1) ch = abxy[1]; else
            ch = abxy[0];
        s += ch;
    }

    if (press(s + abxy[0]) == n){
        s += abxy[0];
    } else if (press(s + abxy[1]) == n){
        s += abxy[1];
    } else s += abxy[2];

    return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |     while (s.size() < n - 1){
      |            ~~~~~~~~~^~~~~~~
combo.cpp:40:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         if (x == s.size()) ch = abxy[2]; else
      |             ~~^~~~~~~~~~~
combo.cpp:41:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if (x == s.size() + 1) ch = abxy[1]; else
      |             ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...