Submission #442639

#TimeUsernameProblemLanguageResultExecution timeMemory
442639nishuzCombo (IOI18_combo)C++17
100 / 100
62 ms548 KiB
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#include "combo.h"
 
using namespace __gnu_pbds;
using namespace std;
 
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define mp make_pair
#define random mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
 
template <typename T> using oset = tree <pair <T, T>, null_type, less <pair <T, T>>, rb_tree_tag, tree_order_statistics_node_update>;
 
template <typename Container>
void Print(Container& container, int starting) {
    auto Start = container.begin() + starting, End = container.end();
    while (Start != End) cout << *(Start++) << " ";
    cout << '\n';
}
 
template <typename T>
void print(T&& t) {cout << t << '\n';}
 
template <typename T, typename... Args>
void print(T&& t, Args&&... args) {
    cout << t << " ";
    print(forward<Args>(args)...);
}    

string guess_sequence(int n) {
    string ans = "A";
    vector <string> c = {"A", "B", "X", "Y"};
    int x = press("AB");
    if (x >= 1) {
        ans = (press("A") ? "A" : "B");
    } else {
        ans = (press("X") ? "X" : "Y");
    }
    vector <string> all;
    for (auto s : c) {
        if (s == ans) continue;
        all.pb(s);
    }
    while ((int)ans.size() != n) {
        if ((int)ans.size() <= n - 2) {
            string t = ans + all[0] + ans + all[1] + all[0] + ans + all[1] + all[1] + ans + all[1] + all[2];
            x = press(t);
            if (x == (int)ans.size()) ans += all[2];
            else if (x == (int)ans.size() + 1) ans += all[0];
            else ans += all[1];
        } else {
            string t = ans + all[0] + ans + all[1];
            x = press(t);
            if (x == (int)ans.size()) ans += all[2];
            else {
                x = press(ans + all[0]);
                if (x == (int)ans.size()) ans += all[1];
                else ans += all[0];
            }
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...