Submission #1070493

#TimeUsernameProblemLanguageResultExecution timeMemory
1070493c2zi6Prisoner Challenge (IOI22_prison)C++17
10 / 100
5 ms856 KiB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "prison.h"

int n;
VVI ans;

const int B = 64;

void prisoner(int x, int y) {
    int type;
    if (x & 1) type = 1;
    else type = 0;

    if (type) {
        /* Es gitem A-i bit@, hamematenq B-i biti het*/
        int ind = (x >> 2)-1;
        int valA = bool(x & 2);
        int valB = bool(y & (1<<ind));
        if (valA < valB) ans[x][y] = -1;
        else if (valB < valA) ans[x][y] = -2;
        else {
            int write = 0;
            ind--;
            if (ind < 0) return;
            write += ((ind+1) << 2);
            write += (valB << 1);
            write += 0;
            ans[x][y] = write;
        }
    } else {
        /* Es unim A-n, A-i bit@ grenq */
        int ind;
        if (x == 0) ind = 8;
        else ind = (x >> 2)-1;
        int val = bool(y & (1<<ind));
        
        int write = 0;
        write += ((ind+1) << 2);
        write += (val << 1);
        write += 1;
        ans[x][y] = write;
    }
}

VVI devise_strategy(int N) {n = N;
    ans = VVI(B, VI(n+1));
    replr(x, 0, B-1) ans[x][0] = (x % 2);
    replr(x, 0, B-1) {
        replr(y, 1, n) {
            prisoner(x, y);
        }
    }
    return ans;

    while (true) {
        int A, B;
        cin >> A >> B;
        int cur = 0;
        rep(i, 20) {
            cout << "Grataxtakin grac e " << cur << " (0b" << bitset<6>(cur) << ")" << endl;
            cout << "Kbace " << (ans[cur][0] ? "B" : "A") << endl;
            int val = (ans[cur][0] ? B : A);
            cout << "Ktesni " << val << endl;
            if (ans[cur][val] == -1) {
                cout << "PATASXAN@ A" << endl;
                goto verj;
            }
            if (ans[cur][val] == -2) {
                cout << "PATASXAN@ B" << endl;
                goto verj;
            }
            /*cout << "Grataxtakin kgre " << ans[cur][val] << " (0b" << bitset<6>(ans[cur][val]) << ")" << endl;*/
            cout << endl;
            cur = ans[cur][val];
        }
verj:;
    }
    /*rep(i, B) {*/
    /*    rep(j, n+1) {*/
    /*        cout << ans[i][j] << " ";*/
    /*    }*/
    /*    cout << endl;*/
    /*}*/

    return ans;
}



#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...