Submission #1208456

#TimeUsernameProblemLanguageResultExecution timeMemory
1208456fskaricaGame (APIO22_game)C++20
0 / 100
3 ms4940 KiB
#include "game.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define fi first
#define se second
#define pii pair<int, int>

const int INF = 1e9;
const int MAX = 1e5 + 10;

int n, k;
int in[MAX], out[MAX];
vector<int> veze[MAX], vezeRev[MAX];

void init(int N, int K) {
    n = N;
    k = K;

    for (int i = 0; i < n; i++) {
        if (i < k) {
            in[i] = i;
            out[i] = i;
        }
        else {
            in[i] = -1;
            out[i] = INF;
        }
    }
}

void rekIn(int u, int novo) {
    if (in[u] >= novo) return;
    in[u] = novo;

    for (int v : veze[u]) {
        rekIn(v, novo);
    }
}

void rekOut(int u, int novo) {
    if (out[u] <= novo) return;
    out[u] = novo;

    for (int v : vezeRev[u]) {
        rekOut(v, novo);
    }
}

int add_teleporter(int x, int y) {
    if (x < k && y < k) {
        return x >= y;
    }

    veze[x].push_back(y);
    vezeRev[y].push_back(x);

    rekIn(y, in[x]);
    rekOut(x, out[y]);

    return in[x] >= out[y];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...