Submission #374792

# Submission time Handle Problem Language Result Execution time Memory
374792 2021-03-08T07:40:18 Z Alex_tz307 Combo (IOI18_combo) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

string guess_sequence(int N) {
    string sol;
    sol.resize(N);
    bool ok = press("AB");
    if(ok) {
        bool first = press("A");
        if(first)
            sol[0] = 'A';
        else
            sol[0] = 'B';
    }
    else {
        bool first = press("X");
        if(first)
            sol[0] = 'X';
        else
            sol[0] = 'Y';
    }
    string mask = "";
    for(const char &ch : "ABXY")
        if(ch != sol[0])
            mask += ch;
    for(int i = 1; i < N - 1; ++i) {
        string ask = sol[i - 1] + mask[0] + sol[i - 1] + mask[1] + mask[0] + sol[i - 1] + mask[1] + mask[1] + sol[i - 1] + mask[1] + mask[2];
        int lg = press(ask);
        if(lg == i)
            sol[i] = mask[0];
        else
            if(lg == i + 1)
                sol[i] = mask[1];
        else
            sol[i] = mask[2];
    }
    if(press(sol + mask[0]) == N)
        return sol + mask[0];
    if(press(sol + mask[1]) == N)
        return sol + mask[1];
    return sol + mask[2];
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:29:132: error: conversion from 'int' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
   29 |         string ask = sol[i - 1] + mask[0] + sol[i - 1] + mask[1] + mask[0] + sol[i - 1] + mask[1] + mask[1] + sol[i - 1] + mask[1] + mask[2];