Submission #713310

#TimeUsernameProblemLanguageResultExecution timeMemory
713310europium콤보 (IOI18_combo)C++17
97 / 100
39 ms540 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;
    string s;

    if (press("A")){
        s = "A";
        moves = {"X", "B", "Y"};
    }
    else if (press("B")){
        s = "B";
        moves = {"A", "X", "Y"};
    }
    else if (press("X")){
        s = "X";
        moves = {"A", "B", "Y"};
    }
    else{
        s = "Y";
        moves = {"A", "B", "X"};
    }

    if (n == 1) return s;

    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 < 2; i++){
        string guess = s + moves[i];

        if (press(guess) == s.size() + 1) return guess;
    }

    return s + moves[2];
}

Compilation message (stderr)

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