Submission #1351621

#TimeUsernameProblemLanguageResultExecution timeMemory
1351621Omar_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++) {
        if (press(c[i])) {
            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 (ll i = 0; i < 2; i++) {
        if (press(s + c[i]) == n) {
            return s+c[i];
        }
    }
    return s + c[2];
}
// void solve() {
    
// }
// int main() {
//     Omar_G
//     // freopen("a.in", "r", stdin);
//     // freopen("a.out", "w", stdout);
//     ll t = 1;
//     //cin >> t;
//     for (ll i = 1; i <= t; i++) {
//         solve();
//     }
//     return 0;
// }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:18: error: could not convert 'c.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
    8 |         if (press(c[i])) {
      |             ~~~~~^~~~~~
      |                  |
      |                  __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
combo.cpp:22:10: error: 'll' was not declared in this scope
   22 |     for (ll i = 0; i < 2; i++) {
      |          ^~
combo.cpp:22:20: error: 'i' was not declared in this scope
   22 |     for (ll i = 0; i < 2; i++) {
      |                    ^