Submission #885794

#TimeUsernameProblemLanguageResultExecution timeMemory
885794sq00콤보 (IOI18_combo)C++14
10 / 100
21 ms1472 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 if(press("X") == 1) {
        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];
            int cost = press(test);
            if(cost == test.size()) {
                current = test;
                break;
            }
            if(i == 1) {
                current += buttons[2];
                break;
            }
        }
        if(current.size() == N) break;
    }
    return current;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     if(current.size() == N) return current;
      |        ~~~~~~~~~~~~~~~^~~~
combo.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             if(cost == test.size()) {
      |                ~~~~~^~~~~~~~~~~~~~
combo.cpp:39:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |         if(current.size() == N) break;
      |            ~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...