답안 #586910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
586910 2022-07-01T02:27:57 Z maomao90 게임 (APIO22_game) C++17
60 / 100
4000 ms 41500 KB
#include <bits/stdc++.h>
#include "game.h"
using namespace std;

#define REP(i, j, k) for (int i = (j); i < (k); i++)
#define RREP(i, j, k) for (int i = (j); i >= (k); i--)

template <class T>
inline bool mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef tuple<int, int, int> iii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int MAXN = 300005;
const int INF = 1000000005;
const ll LINF = 1000000000000000005;

int n, k;
vi adj[MAXN], radj[MAXN];
int mn[MAXN], mx[MAXN];
bool ans;

void init(int N, int K) {
    n = N; k = K;
    REP (i, 0, k) {
        mn[i] = mx[i] = i;
    }
    REP (i, k, n) {
        mn[i] = INF; mx[i] = -INF;
    }
}

void dfs(int u) {
    if (u < k) {
        return;
    }
    if (mn[u] <= mx[u]) {
        ans = 1;
        return;
    }
    for (int v : adj[u]) {
        if (mxto(mx[v], mx[u])) {
            dfs(v);
        }
    }
}

void rdfs(int u) {
    if (u < k) {
        return;
    }
    if (mn[u] <= mx[u]) {
        ans = 1;
        return;
    }
    for (int v : radj[u]) {
        if (mnto(mn[v], mn[u])) {
            rdfs(v);
        }
    }
}

int add_teleporter(int u, int v) {
    if (u < k && v < k) {
        if (v <= u) {
            return 1;
        } else {
            return 0;
        }
    }
    adj[u].pb(v);
    if (mxto(mx[v], mx[u])) {
        dfs(v);
    }
    radj[v].pb(u);
    if (mnto(mn[u], mn[v])) {
        rdfs(u);
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14356 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 7 ms 14288 KB Output is correct
4 Correct 7 ms 14336 KB Output is correct
5 Correct 7 ms 14336 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 7 ms 14288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14356 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 7 ms 14288 KB Output is correct
4 Correct 7 ms 14336 KB Output is correct
5 Correct 7 ms 14336 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 7 ms 14288 KB Output is correct
8 Correct 8 ms 14324 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 7 ms 14288 KB Output is correct
13 Correct 8 ms 14340 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14416 KB Output is correct
16 Correct 7 ms 14288 KB Output is correct
17 Correct 7 ms 14288 KB Output is correct
18 Correct 8 ms 14364 KB Output is correct
19 Correct 8 ms 14288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14356 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 7 ms 14288 KB Output is correct
4 Correct 7 ms 14336 KB Output is correct
5 Correct 7 ms 14336 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 7 ms 14288 KB Output is correct
8 Correct 8 ms 14324 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 7 ms 14288 KB Output is correct
13 Correct 8 ms 14340 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14416 KB Output is correct
16 Correct 7 ms 14288 KB Output is correct
17 Correct 7 ms 14288 KB Output is correct
18 Correct 8 ms 14364 KB Output is correct
19 Correct 8 ms 14288 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 7 ms 14416 KB Output is correct
22 Correct 10 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 11 ms 14432 KB Output is correct
25 Correct 10 ms 14456 KB Output is correct
26 Correct 9 ms 14416 KB Output is correct
27 Correct 9 ms 14380 KB Output is correct
28 Correct 8 ms 14416 KB Output is correct
29 Correct 9 ms 14380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14356 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 7 ms 14288 KB Output is correct
4 Correct 7 ms 14336 KB Output is correct
5 Correct 7 ms 14336 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 7 ms 14288 KB Output is correct
8 Correct 8 ms 14324 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 7 ms 14288 KB Output is correct
13 Correct 8 ms 14340 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14416 KB Output is correct
16 Correct 7 ms 14288 KB Output is correct
17 Correct 7 ms 14288 KB Output is correct
18 Correct 8 ms 14364 KB Output is correct
19 Correct 8 ms 14288 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 7 ms 14416 KB Output is correct
22 Correct 10 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 11 ms 14432 KB Output is correct
25 Correct 10 ms 14456 KB Output is correct
26 Correct 9 ms 14416 KB Output is correct
27 Correct 9 ms 14380 KB Output is correct
28 Correct 8 ms 14416 KB Output is correct
29 Correct 9 ms 14380 KB Output is correct
30 Correct 22 ms 15688 KB Output is correct
31 Correct 13 ms 14928 KB Output is correct
32 Correct 26 ms 16696 KB Output is correct
33 Correct 29 ms 16472 KB Output is correct
34 Correct 1095 ms 17948 KB Output is correct
35 Correct 351 ms 17044 KB Output is correct
36 Correct 42 ms 16432 KB Output is correct
37 Correct 41 ms 16372 KB Output is correct
38 Correct 36 ms 16216 KB Output is correct
39 Correct 32 ms 16284 KB Output is correct
40 Correct 867 ms 18132 KB Output is correct
41 Correct 182 ms 16584 KB Output is correct
42 Correct 115 ms 16460 KB Output is correct
43 Correct 39 ms 17220 KB Output is correct
44 Correct 802 ms 17836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14356 KB Output is correct
2 Correct 8 ms 14288 KB Output is correct
3 Correct 7 ms 14288 KB Output is correct
4 Correct 7 ms 14336 KB Output is correct
5 Correct 7 ms 14336 KB Output is correct
6 Correct 7 ms 14288 KB Output is correct
7 Correct 7 ms 14288 KB Output is correct
8 Correct 8 ms 14324 KB Output is correct
9 Correct 7 ms 14288 KB Output is correct
10 Correct 8 ms 14288 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 7 ms 14288 KB Output is correct
13 Correct 8 ms 14340 KB Output is correct
14 Correct 8 ms 14288 KB Output is correct
15 Correct 8 ms 14416 KB Output is correct
16 Correct 7 ms 14288 KB Output is correct
17 Correct 7 ms 14288 KB Output is correct
18 Correct 8 ms 14364 KB Output is correct
19 Correct 8 ms 14288 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 7 ms 14416 KB Output is correct
22 Correct 10 ms 14416 KB Output is correct
23 Correct 8 ms 14416 KB Output is correct
24 Correct 11 ms 14432 KB Output is correct
25 Correct 10 ms 14456 KB Output is correct
26 Correct 9 ms 14416 KB Output is correct
27 Correct 9 ms 14380 KB Output is correct
28 Correct 8 ms 14416 KB Output is correct
29 Correct 9 ms 14380 KB Output is correct
30 Correct 22 ms 15688 KB Output is correct
31 Correct 13 ms 14928 KB Output is correct
32 Correct 26 ms 16696 KB Output is correct
33 Correct 29 ms 16472 KB Output is correct
34 Correct 1095 ms 17948 KB Output is correct
35 Correct 351 ms 17044 KB Output is correct
36 Correct 42 ms 16432 KB Output is correct
37 Correct 41 ms 16372 KB Output is correct
38 Correct 36 ms 16216 KB Output is correct
39 Correct 32 ms 16284 KB Output is correct
40 Correct 867 ms 18132 KB Output is correct
41 Correct 182 ms 16584 KB Output is correct
42 Correct 115 ms 16460 KB Output is correct
43 Correct 39 ms 17220 KB Output is correct
44 Correct 802 ms 17836 KB Output is correct
45 Correct 258 ms 28068 KB Output is correct
46 Correct 16 ms 17172 KB Output is correct
47 Correct 15 ms 17104 KB Output is correct
48 Correct 322 ms 41500 KB Output is correct
49 Correct 263 ms 35420 KB Output is correct
50 Execution timed out 4022 ms 33152 KB Time limit exceeded
51 Halted 0 ms 0 KB -