제출 #827408

#제출 시각아이디문제언어결과실행 시간메모리
827408AlesL0Combo (IOI18_combo)C++17
0 / 100
15 ms208 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

string guess_sequence(int N){
    vector <char> c = {'A', 'B', 'X', 'Y'};
    string S = "";
    if (press("AB") > 0){
        if (press("A") > 0){
            S = "A";
            c.erase(c.begin());
        }
        else {
            S = "B";
            c.erase(c.begin()+1);
        }
    }
    else {
        if (press("X") > 0){
            S = "X";
            c.erase(c.begin()+2);
        }
        else {
            S = "Y";
            c.erase(c.begin()+3);
        }
    }
    if (S.size() == N)return S;
    for (int i = 1; i < N-1; i++){
        string T = S+c[0]+S+c[1]+c[0]+S+c[1]+c[1]+S+c[2];
        int x = press(T);
        if (x == S.size())S += c[2];
        if (x == S.size()+1)S += c[0];
        if (x == S.size()+2)S += c[1];
    }
    string T = S+c[0]+S+c[1];
    if (press(T) > S.size()){
        T = S+c[0];
        if (press(T) > S.size())S += c[0];
        else S += c[1];
    }
    else S += c[2];
    return S;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:29:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |     if (S.size() == N)return S;
      |         ~~~~~~~~~^~~~
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 (x == S.size())S += c[2];
      |             ~~^~~~~~~~~~~
combo.cpp:34:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if (x == S.size()+1)S += c[0];
      |             ~~^~~~~~~~~~~~~
combo.cpp:35:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if (x == S.size()+2)S += c[1];
      |             ~~^~~~~~~~~~~~~
combo.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     if (press(T) > S.size()){
      |         ~~~~~~~~~^~~~~~~~~~
combo.cpp:40:22: 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 (press(T) > S.size())S += c[0];
      |             ~~~~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...