Submission #947202

#TimeUsernameProblemLanguageResultExecution timeMemory
947202Nhoksocqt1Prisoner Challenge (IOI22_prison)C++17
5 / 100
34 ms62332 KiB
#ifndef Nhoksocqt1
    #include "prison.h"
#endif // Nhoksocqt1
#include<bits/stdc++.h>
using namespace std;

#define inf 0x3f3f3f3f
#define sz(x) int((x).size())
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;

template<class X, class Y>
	inline bool maximize(X &x, const Y &y) {return (x < y ? x = y, 1 : 0);}
template<class X, class Y>
	inline bool minimize(X &x, const Y &y) {return (x > y ? x = y, 1 : 0);}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Random(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int MAXN = 5003;

int ans[MAXN][MAXN], nArr;

vector<vector<int>> devise_strategy(int _N) {
    nArr = _N;
    for (int i = 0; i <= nArr; ++i) {
        ans[i][0] = (i != 0);
        for (int j = 1; j <= nArr; ++j)
            ans[i][j] = -1;
    }

    for (int j = 1; j <= nArr; ++j)
        ans[0][j] = j;

    for (int i = 1; i <= nArr; ++i) {
        for (int j = 1; j <= nArr; ++j) {
            if(i != j)
                ans[i][j] = (i < j) ? -1 : -2;
        }
    }

    vector<vector<int>> res;

    int x(nArr);
    for (int i = 0; i <= x; ++i) {
        vector<int> p;
        for (int j = 0; j <= nArr; ++j)
            p.push_back(ans[i][j]);

        res.push_back(p);
    }

    return res;
}

#ifdef Nhoksocqt1

int main(void) {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    #define TASK "prison"
    if(fopen(TASK".inp", "r")) {
        freopen(TASK".inp", "r", stdin);
        freopen(TASK".out", "w", stdout);
    }

    int _N;
    cin >> _N;

    vector<vector<int>> ans = devise_strategy(_N);
    cout << "X USED: " << sz(ans) - 1 << '\n';
    for (int i = 0; i < sz(ans); ++i) {
        for (int j = 0; j < sz(ans[i]); ++j)
            cout << ans[i][j] << ' ';

        cout << '\n';
    }

    return 0;
}

#endif // Nhoksocqt1
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...