Submission #1319956

#TimeUsernameProblemLanguageResultExecution timeMemory
1319956ThanhsCombo (IOI18_combo)C++20
5 / 100
0 ms404 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

#define name "TENBAI"
#define fi first
#define se second
#define endl '\n'
#define setmin(x, y) x = min((x), (y))
#define setmax(x, y) x = max((x), (y))
#define sqr(x) ((x) * (x))
#define all(x) x.begin(), x.end()

mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}

string s;

string guess_sequence(int N)
{
    s = "ABXY";
    char f;
    f = (press("AB") ? (press("A") ? 'A' : 'B') : (press("X") ? 'X' : 'Y'));
    s.erase(find(all(s), f));
    string s1, s2;
    s1 = f + string(N, s[0]), s2 = f + string(N, s[1]);
    int cr = 1;
    while (cr < N)
    {
        int t = press(s1 + s2);
        if (s1.back() != s2.back())
        {
            char x = s1.back(), y = s2.back(), z = accumulate(all(s), 0) - x - y;
            if (t == cr)
            {
                s1.resize(cr); s2.resize(cr);
                s1 += z; s2 += z;
                s1 += string(N, x); s2 += string(N, y);
                cr++;
            }
            else
            {
                cr = t;
                s1.resize(cr); s2.resize(cr);
                s1 += string(N, z); s2 += string(N, z);
            }
        }
        else
        {
            char x = s1[cr - 1], y = s2[cr - 1], z = accumulate(all(s), 0) - x - y;
            if (t == cr)
            {
                s1.resize(cr); s2.resize(cr);
                s1 += y; s2 += x;
                s1 += string(N, x); s2 += string(N, y);
                cr++;
            }
            else
            {
                cr = t;
                s1.resize(cr); s2.resize(cr);
                s1 += string(N, z); s2 += string(N, z);
            }
        }
    }
    s1.resize(cr); s2.resize(cr);
    if (s1 == s2)
        return s1;
    return (press(s1) == N ? s1 : s2);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...