Submission #789681

# Submission time Handle Problem Language Result Execution time Memory
789681 2023-07-21T18:07:25 Z GusterGoose27 Game (APIO22_game) C++17
2 / 100
7 ms 14416 KB
#include "game.h"

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 3e5+5;
const int MAXB = 20;
vector<int> edges[MAXN];
vector<int> rev[MAXN];
int mxin[MAXN];
int mnout[MAXN];
int n, k;

bool rev_dfs(int cur) {
    if (mnout[cur] <= mxin[cur]) return 1;
    for (int nxt: rev[cur]) {
        if (mnout[cur] < mnout[nxt]) {
            mnout[nxt] = mnout[cur];
            rev_dfs(nxt);
        }
    }
    return 0;
}

bool dfs(int cur) {
    if (mnout[cur] <= mxin[cur]) return 1;
    for (int nxt: edges[cur]) {
        if (mxin[cur] > mxin[nxt]) {
            mxin[nxt] = mxin[cur];
            dfs(nxt);
        }
    }
    return 0;
}

bool add_edge(int u, int v) {
    edges[u].push_back(v);
    rev[v].push_back(u);
    if (v < k && mnout[u] > v) {
        mnout[u] = v;
        if (rev_dfs(u)) return 1;
    }
    if (mnout[v] < mnout[u]) {
        mnout[u] = mnout[v];
        if (rev_dfs(u)) return 1;
    }
    if (mxin[u] > mxin[v]) {
        mxin[v] = mxin[u];
        if (dfs(v)) return 1;
    }
    return 0;
}

void init(int N, int K) {
    n = N;
    k = K;
    fill(mxin, mxin+n, -1);
    fill(mnout, mnout+n, n);
    for (int i = 0; i < k; i++) {
        mxin[i] = mnout[i] = i+1;
    }
}

int add_teleporter(int u, int v) {
    return add_edge(u, v);
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 14288 KB Output is correct
2 Correct 6 ms 14320 KB Output is correct
3 Correct 6 ms 14288 KB Output is correct
4 Correct 6 ms 14388 KB Output is correct
5 Correct 6 ms 14392 KB Output is correct
6 Correct 6 ms 14288 KB Output is correct
7 Correct 6 ms 14412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 14288 KB Output is correct
2 Correct 6 ms 14320 KB Output is correct
3 Correct 6 ms 14288 KB Output is correct
4 Correct 6 ms 14388 KB Output is correct
5 Correct 6 ms 14392 KB Output is correct
6 Correct 6 ms 14288 KB Output is correct
7 Correct 6 ms 14412 KB Output is correct
8 Correct 6 ms 14288 KB Output is correct
9 Correct 7 ms 14416 KB Output is correct
10 Correct 6 ms 14288 KB Output is correct
11 Correct 6 ms 14288 KB Output is correct
12 Correct 6 ms 14288 KB Output is correct
13 Correct 6 ms 14364 KB Output is correct
14 Incorrect 6 ms 14288 KB Wrong Answer[1]
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 14288 KB Output is correct
2 Correct 6 ms 14320 KB Output is correct
3 Correct 6 ms 14288 KB Output is correct
4 Correct 6 ms 14388 KB Output is correct
5 Correct 6 ms 14392 KB Output is correct
6 Correct 6 ms 14288 KB Output is correct
7 Correct 6 ms 14412 KB Output is correct
8 Correct 6 ms 14288 KB Output is correct
9 Correct 7 ms 14416 KB Output is correct
10 Correct 6 ms 14288 KB Output is correct
11 Correct 6 ms 14288 KB Output is correct
12 Correct 6 ms 14288 KB Output is correct
13 Correct 6 ms 14364 KB Output is correct
14 Incorrect 6 ms 14288 KB Wrong Answer[1]
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 14288 KB Output is correct
2 Correct 6 ms 14320 KB Output is correct
3 Correct 6 ms 14288 KB Output is correct
4 Correct 6 ms 14388 KB Output is correct
5 Correct 6 ms 14392 KB Output is correct
6 Correct 6 ms 14288 KB Output is correct
7 Correct 6 ms 14412 KB Output is correct
8 Correct 6 ms 14288 KB Output is correct
9 Correct 7 ms 14416 KB Output is correct
10 Correct 6 ms 14288 KB Output is correct
11 Correct 6 ms 14288 KB Output is correct
12 Correct 6 ms 14288 KB Output is correct
13 Correct 6 ms 14364 KB Output is correct
14 Incorrect 6 ms 14288 KB Wrong Answer[1]
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 14288 KB Output is correct
2 Correct 6 ms 14320 KB Output is correct
3 Correct 6 ms 14288 KB Output is correct
4 Correct 6 ms 14388 KB Output is correct
5 Correct 6 ms 14392 KB Output is correct
6 Correct 6 ms 14288 KB Output is correct
7 Correct 6 ms 14412 KB Output is correct
8 Correct 6 ms 14288 KB Output is correct
9 Correct 7 ms 14416 KB Output is correct
10 Correct 6 ms 14288 KB Output is correct
11 Correct 6 ms 14288 KB Output is correct
12 Correct 6 ms 14288 KB Output is correct
13 Correct 6 ms 14364 KB Output is correct
14 Incorrect 6 ms 14288 KB Wrong Answer[1]
15 Halted 0 ms 0 KB -