Submission #1210119

#TimeUsernameProblemLanguageResultExecution timeMemory
1210119FatonimMensza (COI22_mensza)C++20
0 / 100
13 ms584 KiB
#include <bits/stdc++.h>
using namespace std;

#ifdef ONPC
#include "debug.h"
#else
#define dbg(...)
#endif

#define ll long long
#define int long long
#define ld long double
#define pi pair<int, int>
#define sz(a) ((int)(a.size()))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(n) ((n) * (n))
#define divup(a, b) (((a) + (b)-1) / (b))
#define popcount(n) __builtin_popcountll(n)
#define clz(n) __builtin_clzll(n)
#define Fixed(a) cout << fixed << setprecision(12) << a;

template <class T> bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template <class T> bool chmax(T& a, const T& b) { return b > a ? a = b, 1 : 0; }

const int mod = 998244353; // 998244353 1e9 + 7
const ll inf = (ll)(1e18) + 7;
const ld eps = 1e-9;

const int B = 8;
const int N = 1000 + 3;
const int logn = 20;
const int maxn = 2e5 + 7;
/////////////////////////solve/////////////////////////

int L;

void cpu_wait(ll s) {
    auto tm = chrono::system_clock::now();
    while (chrono::duration_cast<chrono::milliseconds>(
        chrono::system_clock::now() - tm)
        .count() < s) {
    }
}

vector<int> decode_a(int a) {
    vector<int> res;
    for (int j = 0; j < B; ++j) {
        if (a >> j & 1) {
            for (int i = 1; i <= j + 1; ++i) {
                res.push_back(j + 1);
            }
        }
    }
    assert(sz(res) <= L);
    return res;
}

vector<int> decode_b(int b) {
    vector<int> res;
    for (int j = 0; j < B; ++j) {
        if (b >> j & 1) {
            for (int i = 1; i <= j + 1 + B; ++i) {
                res.push_back(j + 1 + B);
            }
        }
    }
    assert(sz(res) <= L);
    return res;
}

bool encode(int n, vector<int> c) {
    int a = 0, b = 0;
    for (auto x : c) {
        if (x <= B) {
            int j = x - 1;
            a += 1 << j;
        }
        else {
            int j = x - 1 - B;
            b += 1 << j;
        }
    }
    // dbg(a, b);
    cpu_wait(b);
    return a > b;
}

vector<int> get_c(vector<int> res1, vector<int> res2) {
    vector<int> c;
    map <int, int> mp;
    for (auto x : res1) {
        mp[x]++;
    }
    for (auto x : res2) {
        mp[x]++;
    }
    for (auto [x, cnt] : mp) {
        c.push_back(cnt);
    }
    sort(all(c));
    // dbg(c);
    return c;
}

void solve() {
    cin >> L;

    int t;
    cin >> t;

    vector<int> res1, res2;
    while (t--) {
        string cur;
        cin >> cur;
        if (cur == "alojzije") {
            int a;
            cin >> a;
            vector<int> res = decode_a(a);
            cout << sz(res) << " ";
            for (auto x : res) cout << x << " ";
            cout << endl;

            // res1 = res;
        }
        else if (cur == "benjamin") {
            int b;
            cin >> b;
            vector<int> res = decode_b(b);
            cout << sz(res) << " ";
            for (auto x : res) cout << x << " ";
            cout << endl;

            // res2 = res;
        }
        else {
            int n;
            cin >> n;

            vector<int> c(n);
            for (int i = 0; i < n; ++i) {
                cin >> c[i];
            }

            bool res = encode(n, c);
            cout << (res ? "A" : "B") << endl;
        }
    }
    // vector<int> c = get_c(res1, res2);
    // encode(sz(c), c);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

#ifdef ONPC
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...