Submission #314133

# Submission time Handle Problem Language Result Execution time Memory
314133 2020-10-18T16:18:17 Z lauran Combo (IOI18_combo) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int n) {
    string ret;

    // 1. aflu primul caracter
    int ans = press("AB");
    if (ans == 0) {
        ans = press("Y");
        if (ans == 1)
            ret += "Y";
        else
            ret += "X";
    }
    else if (ans == 1) {
        ans = press("A");
        if (ans == 1)
            ret += "A";
        else
            ret += "B";
    }
    else
        ret += "A";

    vector <string> rest;
    if (ret[0] != 'A') rest.push_back("A");
    if (ret[0] != 'B') rest.push_back("B");
    if (ret[0] != 'X') rest.push_back("X");
    if (ret[0] != 'Y') rest.push_back("Y");

    for (int i = 2; i <= n - 1; i++) {
        ans = press((ret + rest[0]) + (ret + rest[1] + rest[0]) + ret + (rest[1] + rest[1]) + ret + (rest[1] + rest[2]));
        if (ans == ret.size() + 1)
            ret += rest[0];
        else if (ans == ret.size() + 2)
            ret += rest[1];
        else if (ans == ret.size())
            ret += rest[2];
    }

    if (n > 1) for (int i = 0; i <= 1; i++) {
        ans = press(ret + rest[i]);
        if (ans == ret.size() + 1)
            return ret + rest[i];
    }
    if (n > 1) return ret + rest[2];
    return ret;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:15: error: 'press' was not declared in this scope
    8 |     int ans = press("AB");
      |               ^~~~~
combo.cpp:34:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if (ans == ret.size() + 1)
      |             ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         else if (ans == ret.size() + 2)
      |                  ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:38:22: 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 (ans == ret.size())
      |                  ~~~~^~~~~~~~~~~~~
combo.cpp:44:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         if (ans == ret.size() + 1)
      |             ~~~~^~~~~~~~~~~~~~~~~