Submission #1164127

#TimeUsernameProblemLanguageResultExecution timeMemory
1164127canhnam357Combo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
// string S = "ABXYY";
// // z[i] = length of longest common prefix of s[0..N] and s[i..N]
// vector<int> zfunc(const string& s) {
//     int n = (int)s.length();
//     vector<int> z(n);
//     z[0] = n;
//     for (int i = 1, l = 0, r = 0; i < n; ++i) {
//         if (i <= r)
//             z[i] = min(r - i + 1, z[i - l]);
//         while (i + z[i] < n && s[z[i]] == s[i + z[i]])
//             ++z[i];
//         if (i + z[i] - 1 > r)
//             l = i, r = i + z[i] - 1;
//     }
//     return z;
// }
// int press(string p)
// {
//     string s = S + "#" + p;
//     vector<int> z = zfunc(s);
//     return *max_element(z.begin() + (int)(S.size()), z.end());
// }
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);
long long get_random(long long l, long long r, bool non_zero = 0)
{
    assert(l <= r);
    long long res;
    while (true)
    {
        res = mt() % (r - l + 1) + l;
        if (non_zero && !res) continue;
        break;
    }
    return res;
}
string guess_sequence(int N)
{
    int asked = 0;
    string chars = "ABXY";
    string t = "";
    for (int i = 0; i < 4; i++)
    {
        t += chars[i];
        asked++;
        if (press(t))
        {
            chars.erase(i, 1);
            break;
        }
        t.pop_back();
    }
    vector<int> ord = {0, 1, 2};
    for (int i = 2; i <= N; i++)
    {
        shuffle(ord.begin(), ord.end(), mt);
        for (int j = 0; j < 3; j++)
        {
            t += chars[ord[j]];
            asked++;
            if (press(t) == i)
            {
                break;
            }
            t.pop_back();
        }
    }
    //cout << "ASKED " << asked << '\n';
    return t;
}
// int main()
// {
//     cout << guess_sequence(S.size());
//     return 0;
// }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:48:13: error: 'press' was not declared in this scope
   48 |         if (press(t))
      |             ^~~~~
combo.cpp:63:17: error: 'press' was not declared in this scope
   63 |             if (press(t) == i)
      |                 ^~~~~