Submission #580193

# Submission time Handle Problem Language Result Execution time Memory
580193 2022-06-20T17:19:45 Z pawned Game (APIO22_game) C++17
2 / 100
11 ms 14404 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;

int N, K;

vi adj[300005];
vi rev[300005];

ii range[300005];

void init(int n, int k) {
    N = n;
    K = k;
    for (int i = 1; i <= K; i++) {
        if (i < K) {
            adj[i].pb(i + 1);
            rev[i + 1].pb(i);
        }
        range[i] = {i, i};
    }
    for (int i = K + 1; i <= N; i++) {
        range[i] = {0, K + 1};
    }
}

bool dfs(int u, int v) {
    if (range[u].se <= range[v].fi) // rip
        return false;
    if (range[u].fi >= range[v].se) // good
        return true;
    if (range[v].fi < range[u].fi) {
        range[v].fi = range[u].fi;
        for (int i : adj[v]) {
            if (dfs(v, i))
                return true;
        }
    }
    if (range[u].se > range[v].se) {
        range[u].se = range[v].se;
        for (int i : rev[u]) {
            if (dfs(i, u))
                return true;
        }
    }
    return false;
}

int add_teleporter(int u, int v) {
    u++; v++;
    if (u >= v && u <= K)
        return 1;
    if (u == v)
        return 0;
    adj[u].pb(v);
    adj[v].pb(u);
    return dfs(u, v);
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14368 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14372 KB Output is correct
6 Correct 11 ms 14288 KB Output is correct
7 Correct 7 ms 14404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14368 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14372 KB Output is correct
6 Correct 11 ms 14288 KB Output is correct
7 Correct 7 ms 14404 KB Output is correct
8 Correct 10 ms 14384 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Incorrect 7 ms 14344 KB Wrong Answer[1]
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14368 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14372 KB Output is correct
6 Correct 11 ms 14288 KB Output is correct
7 Correct 7 ms 14404 KB Output is correct
8 Correct 10 ms 14384 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Incorrect 7 ms 14344 KB Wrong Answer[1]
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14368 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14372 KB Output is correct
6 Correct 11 ms 14288 KB Output is correct
7 Correct 7 ms 14404 KB Output is correct
8 Correct 10 ms 14384 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Incorrect 7 ms 14344 KB Wrong Answer[1]
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14368 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 8 ms 14288 KB Output is correct
4 Correct 8 ms 14288 KB Output is correct
5 Correct 8 ms 14372 KB Output is correct
6 Correct 11 ms 14288 KB Output is correct
7 Correct 7 ms 14404 KB Output is correct
8 Correct 10 ms 14384 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Incorrect 7 ms 14344 KB Wrong Answer[1]
11 Halted 0 ms 0 KB -