Submission #199206

#TimeUsernameProblemLanguageResultExecution timeMemory
199206joylintpCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

string guess_sequence(int n)
{
    string ans;
    set<char> s = {'A', 'B', 'X', 'Y'};

    for (char c : s)
        if (press(ret + c) == 1)
        {
            ret += c;
            break;
        }
    if (ret.empty())
        ret = "Y";
    s.erase(ret[0]);

    for (int i = 1; i < n; i++)
    {
        bool suc = false;
        for (char c : s)
            if (press(ret + c) == (int)ret.size() + 1)
            {
                ret += c;
                suc = true;
            }
        if (!suc)
            ret += *prev(s.end());
    }

    return ret;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:12:19: error: 'ret' was not declared in this scope
   12 |         if (press(ret + c) == 1)
      |                   ^~~
combo.cpp:17:9: error: 'ret' was not declared in this scope
   17 |     if (ret.empty())
      |         ^~~
combo.cpp:19:13: error: 'ret' was not declared in this scope
   19 |     s.erase(ret[0]);
      |             ^~~