Submission #1351196

#TimeUsernameProblemLanguageResultExecution timeMemory
1351196pandaa73Casino (JOI26_casino)C++20
100 / 100
285 ms852 KiB
#include <bits/stdc++.h>
using namespace std;

#define ff endl
#define lf "\n"
#define fi first
#define se second
#define _ << ' ' <<
#define all(x) begin(x),end(x)
#define rall(x) rbegin(x),rend(x)

#ifdef DEBUG

constexpr bool IS_DEBUG = 1;

#define infor(fmt, ...) do { print(stderr, fmt, ##__VA_ARGS__); } while(0)
#define infof(fmt, ...) do { println(stderr, fmt, ##__VA_ARGS__); } while(0)

#else

constexpr bool IS_DEBUG = 0;

#define infor(fmt, ...)
#define infof(fmt, ...)

#endif

using ll = long long;

using pll = pair<ll, ll>;
using pii = pair<int, int>;

constexpr int LOG = 20;
constexpr int MOD = 1e9+7;
constexpr int MAXN = 8;

namespace {

mt19937 timmy_loves_gambling(73);

const vector<vector<int>> SEN = {
    {0, 1, 1, 1, 1, 1, 1, 1},
    {0, 0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 0, 0}
};

void next(int &i, int &j) {
    j += 1;
    if(j == MAXN) {
        j = 0;
        i += 1;

        if(i == MAXN) i = 0;
    }
}

};

vector<vector<int>> Azzurro(int N, int L, string S) {
    vector G(N, vector<int>(N));

    int x = 0, y = 0;
    for(int i = 0; i < L; ++i, next(x, y)) {
        while(SEN[x][y]) next(x, y);

        G[x][y] = S[i] - 'A';
    }

    for(int i = 1; i <= 13; ++i) {
        x = max(0, i - N + 1), y = i - x;

        for(int r = x, c = y; 0 <= min(r, c) && max(r, c) < N;
                r += 2, c -= 2) {
            G[x][y] ^= G[r][c];
        }
    }

    return G;
}
#include <bits/stdc++.h>
using namespace std;

#define ff endl
#define lf "\n"
#define fi first
#define se second
#define _ << ' ' <<
#define all(x) begin(x),end(x)
#define rall(x) rbegin(x),rend(x)

#ifdef DEBUG

constexpr bool IS_DEBUG = 1;

#define infor(fmt, ...) do { print(stderr, fmt, ##__VA_ARGS__); } while(0)
#define infof(fmt, ...) do { println(stderr, fmt, ##__VA_ARGS__); } while(0)

#else

constexpr bool IS_DEBUG = 0;

#define infor(fmt, ...)
#define infof(fmt, ...)

#endif

using ll = long long;

using pll = pair<ll, ll>;
using pii = pair<int, int>;

constexpr int LOG = 20;
constexpr int MOD = 1e9+7;
constexpr int MAXN = 8;

namespace {

mt19937 timmy_loves_gambling(73);

const vector<vector<int>> SEN = {
    {0, 1, 1, 1, 1, 1, 1, 1},
    {0, 0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 0, 0}
};

void next(int &i, int &j) {
    j += 1;
    if(j == MAXN) {
        j = 0;
        i += 1;

        if(i == MAXN) i = 0;
    }
}

};

string Bordeaux(int N, int L, vector<vector<int>> T) {
    vector pass(N + 1, vector<int>(N + 1));
    for(int i = 1; i <= 13; ++i) {
        int x = max(0, i - N + 1), y = i - x;

        int v = 0;
        for(int r = x, c = y; 0 <= min(r, c) && max(r, c) < N;
                r += 2, c -= 2) {
            v ^= T[r][c];
        }

        for(int r = x, c = y; 0 <= min(r, c) && max(r, c) < N; ++r, c--) {
            pass[r][c] = v;
            v ^= 1;
        }
    }

    pass[0][0] = pass[N - 1][N - 1] = 1;

    int x = 0, y = 0;
    while(x != N - 1 || y != N - 1) {
        T[x][y] ^= 1;

        (pass[x + 1][y] ? x : y) += 1;
    }

    T[x][y] ^= 1;

    string S(L, 'A');

    x = 0, y = 0;
    for(int i = 0; i < L; ++i, next(x, y)) {
        while(SEN[x][y]) next(x, y);

        S[i] += T[x][y];
    }

    return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...