Submission #1351630

#TimeUsernameProblemLanguageResultExecution timeMemory
1351630Omar_GCombo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int n) {
    string c = "ABXY", s = "";
    for (int i = 0; i < 3; i++) {
      string b = c[i];
        if (press(b)) {
            s = c[i];
            swap(c[i], c[3]);
            break;
        }
    }
    if (!s.size()) s = c[3];
    while (s.size() + 1 < n) {
        string q = s + c[0] + c[0] + s + c[0] + c[1] + s + c[0] + c[2] + s + c[1];
        int a = press(q);
        if (a == s.size() + 2) s += c[0];
        else if (a == s.size() + 1) s += c[1];
        else s += c[2];
    }
    for (int i = 0; i < 2; i++) {
        if (press(s + c[i]) == n) {
            return s+c[i];
        }
    }
    return s + c[2];
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:21: error: conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
    8 |       string b = c[i];
      |                     ^