Submission #1208439

#TimeUsernameProblemLanguageResultExecution timeMemory
1208439fskarica게임 (APIO22_game)C++20
0 / 100
3 ms5116 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 < k; i++) {
        in[i] = i;
        out[i] = i;
    }

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

void updateIn(int pos, int novo) {
    if (in[pos] <= novo) return;

    in[pos] = novo;
    for(auto e : vezeRev[pos]) {
        updateIn(e, novo);
    }
}

void updateOut(int pos, int novo) {
    if (out[pos] >= novo) return;

    out[pos] = novo;
    for(auto e : veze[pos]) {
        updateOut(e, novo);
    }
}

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

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

    updateIn(y, in[x]);
    updateOut(x, out[y]);

    return in[x] >= out[y];
}

//int main() {
//
//}
#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...