제출 #427656

#제출 시각아이디문제언어결과실행 시간메모리
427656daanolavCombo (IOI18_combo)C++14
0 / 100
1 ms328 KiB
#include "combo.h"
#include <string>

using namespace std;

string characters[4];


std::string guess_sequence(int N) {
    characters[0] = "A";
    characters[1] = "B";
    characters[2] = "X";
    characters[3] = "Y";

    string start = "";
    int res = press("AB");

    if(res >= 1) {
        if(res == 2) {
            start = "AB";
        } else {
            res = press("AX");
            if(res == 0) {
                start = "B";
            } else if(res == 1) {
                start = "A";
            } else {
                start = "AX";
            }
        }
    } else {
        res = press("XA");
        if(res == 0) {
            start = "Y";
        } else if(res == 1) {
            start = "X";
        } else {
            start = "XA";
        }
    }

    string first = "" + start.at(0);
    string notFirst[3];
    int i = 0;
    for(string c : characters) {
        if(first == c) {
            continue;
        }
        notFirst[i] = c;
        ++i;
    }

    while(start.size() != N) {
        res = press(start + notFirst[0] + start + notFirst[1] + notFirst[0]);
        if(res == start.size()) {
            start = start + notFirst[2];
        } else if(res == start.size() + 2) {
            start = start + notFirst[1] + notFirst[0];
        } else {
            res = press(start + notFirst[0] + notFirst[0]);
            if(res == start.size()) {
                start = start + notFirst[1];
            } else if(res == start.size() + 2) {
                start = start + notFirst[0] + notFirst[0];
            } else {
                start = start + notFirst[0];
            }
        }
    }


    return "";
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:53:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |     while(start.size() != N) {
      |           ~~~~~~~~~~~~~^~~~
combo.cpp:55:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         if(res == start.size()) {
      |            ~~~~^~~~~~~~~~~~~~~
combo.cpp:57:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         } else if(res == start.size() + 2) {
      |                   ~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:61:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |             if(res == start.size()) {
      |                ~~~~^~~~~~~~~~~~~~~
combo.cpp:63:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |             } else if(res == start.size() + 2) {
      |                       ~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...