# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1208455 | fskarica | Game (APIO22_game) | C++20 | 0 ms | 0 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);
propagirajIn(y, in[x]);
propagirajOut(x, out[y]);
return in[x] >= out[y];
}