Submission #713279

#TimeUsernameProblemLanguageResultExecution timeMemory
713279europiumCombo (IOI18_combo)C++17
88 / 100
35 ms620 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <iterator>
#include <set>
#include <map>
#include <math.h>
#include <iomanip>
#include <unordered_set>
#include "combo.h"
using namespace std;

string guess_sequence(int n) {
    vector<string> moves = {"A", "B", "X", "Y"};

    string s = "";

    for (int i = 0; i < 4; i++){
        string guess = moves[i];

        if (press(guess) == 1){
            s += moves[i];

            auto it = find(moves.begin(), moves.end(), guess);
            moves.erase(it);
            break;
        }
    }

    while (s.size() < n - 1){
        string guess = s + moves[0] + s + moves[1] + moves[0] + s + moves[1] + moves[1] + s + moves[1] + moves[2];
        int coins = press(guess);

        if (coins == s.size()) s += moves[2];
        else if (coins == s.size() + 1) s += moves[0];
        else if (coins == s.size() + 2) s += moves[1];
    }

    for (int i = 0; i < 3; i++){
        string guess = s + moves[i];

        if (press(guess) == s.size() + 1){
            s += moves[i];
            break;
        }
    }

    return s;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:33:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |     while (s.size() < n - 1){
      |            ~~~~~~~~~^~~~~~~
combo.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         if (coins == s.size()) s += moves[2];
      |             ~~~~~~^~~~~~~~~~~
combo.cpp:38:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         else if (coins == s.size() + 1) s += moves[0];
      |                  ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:39:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         else if (coins == s.size() + 2) s += moves[1];
      |                  ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:45:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         if (press(guess) == s.size() + 1){
      |             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...