제출 #885803

#제출 시각아이디문제언어결과실행 시간메모리
885803sq00콤보 (IOI18_combo)C++14
30 / 100
19 ms1536 KiB
#include <bits/stdc++.h>
#include "combo.h"
 
using namespace std;
 
string guess_sequence(int N) {
  string buttons = "", firstBtn = "";
    if(press("A") == 1) {
        firstBtn = "A";
        buttons = "BYX";
    }
    else if(press("B") == 1) {
        firstBtn = "B";
        buttons = "AYX";
    }
    else if(press("Y") == 1) {
        firstBtn = "Y";
        buttons = "ABX";
    } else {
        firstBtn = "X";
        buttons = "ABY";
    }
    string current = firstBtn;
    if(current.size() == N) return current;
    while(true) {
        for(int i = 0; i < (int)buttons.size(); i++) {
            string test = current + buttons[i];
            string pressed = test;
            if(test.size() < N) pressed += test + buttons[i + 1];
            int cost = press(pressed);
            if(cost == test.size()) {
                current = test;
                break;
            } else if(cost == test.size() + 1) {
                current = test + buttons[i + 1];
                break;
            }
            if(i == 1) {
                current += buttons[2];
                break;
            }
        }
        if(current.size() == N) break;
    }
    return current;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     if(current.size() == N) return current;
      |        ~~~~~~~~~~~~~~~^~~~
combo.cpp:29:28: 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(test.size() < N) pressed += test + buttons[i + 1];
      |                ~~~~~~~~~~~~^~~
combo.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             if(cost == test.size()) {
      |                ~~~~~^~~~~~~~~~~~~~
combo.cpp:34:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             } else if(cost == test.size() + 1) {
      |                       ~~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:43:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |         if(current.size() == N) break;
      |            ~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...