답안 #739141

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
739141 2023-05-10T03:42:01 Z PixelCat 게임 (APIO22_game) C++17
60 / 100
4000 ms 40136 KB
#include "game.h"
#ifdef NYAOWO
#include "grader.cpp"
#endif

#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define eb emplace_back
using namespace std;
using LL = long long;
using pii = pair<int, int>;

const int MAXN = 300030;

int n, k, ok;
vector<int> adj[MAXN], rev[MAXN];
int mx[MAXN]; // max special that can reach i
int mn[MAXN]; // min special that i can reach

void init(int _n, int _k) {
    n = _n; k = _k;
    ok = 0;
    For(i, 0, n - 1) {
        adj[i].clear();
        rev[i].clear();
        mx[i] = -1;
        mn[i] = n + 1;
    }
    For(i, 0, k - 2) {
        mx[i + 1] = i;
        mn[i] = i + 1;
        adj[i].eb(i + 1);
        rev[i + 1].eb(i);
    }
}

void dfs_mx(int x, int m) {
    if(mx[x] >= m) return;
    mx[x] = m;
    if(mx[x] >= mn[x]) {
        ok = 1; return;
    }
    for(auto &i:adj[x]) {
        dfs_mx(i, m);
    }
}

void dfs_mn(int x, int m) {
    if(mn[x] <= m) return;
    mn[x] = m;
    if(mx[x] >= mn[x]) {
        ok = 1; return;
    }
    for(auto &i:rev[x]) {
        dfs_mn(i, m);
    }
}

int add_teleporter(int u, int v) {
    if(u < k && v < k) {
        if(u >= v) return 1;
        return 0;
    }
    adj[u].eb(v);
    rev[v].eb(u);
    if(u < k) {
        dfs_mx(v, u);
        dfs_mn(u, mn[v]);
    } else if(v < k) {
        dfs_mx(v, mx[u]);
        dfs_mn(u, v);
    } else {
        dfs_mx(v, mx[u]);
        dfs_mn(u, mn[v]);
    }

    // cout << "mx:";
    // For(i, 0, n - 1) cout << " " << mx[i];
    // cout << "\n";
    // cout << "mn:";
    // For(i, 0, n - 1) cout << " " << mn[i];
    // cout << "\n";

    return ok;
}

/*

4
0
2

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 7 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 7 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 7 ms 14292 KB Output is correct
10 Correct 7 ms 14288 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 8 ms 14288 KB Output is correct
14 Correct 7 ms 14408 KB Output is correct
15 Correct 7 ms 14404 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 7 ms 14288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 7 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 7 ms 14292 KB Output is correct
10 Correct 7 ms 14288 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 8 ms 14288 KB Output is correct
14 Correct 7 ms 14408 KB Output is correct
15 Correct 7 ms 14404 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 7 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 7 ms 14416 KB Output is correct
23 Correct 9 ms 14452 KB Output is correct
24 Correct 12 ms 14440 KB Output is correct
25 Correct 10 ms 14432 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 10 ms 14444 KB Output is correct
28 Correct 9 ms 14428 KB Output is correct
29 Correct 10 ms 14436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 7 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 7 ms 14292 KB Output is correct
10 Correct 7 ms 14288 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 8 ms 14288 KB Output is correct
14 Correct 7 ms 14408 KB Output is correct
15 Correct 7 ms 14404 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 7 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 7 ms 14416 KB Output is correct
23 Correct 9 ms 14452 KB Output is correct
24 Correct 12 ms 14440 KB Output is correct
25 Correct 10 ms 14432 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 10 ms 14444 KB Output is correct
28 Correct 9 ms 14428 KB Output is correct
29 Correct 10 ms 14436 KB Output is correct
30 Correct 22 ms 15712 KB Output is correct
31 Correct 11 ms 15088 KB Output is correct
32 Correct 24 ms 16596 KB Output is correct
33 Correct 23 ms 16424 KB Output is correct
34 Correct 953 ms 17408 KB Output is correct
35 Correct 340 ms 16856 KB Output is correct
36 Correct 44 ms 16576 KB Output is correct
37 Correct 35 ms 16424 KB Output is correct
38 Correct 38 ms 16240 KB Output is correct
39 Correct 36 ms 16396 KB Output is correct
40 Correct 816 ms 17636 KB Output is correct
41 Correct 184 ms 16552 KB Output is correct
42 Correct 112 ms 16416 KB Output is correct
43 Correct 48 ms 17068 KB Output is correct
44 Correct 761 ms 17436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14288 KB Output is correct
2 Correct 7 ms 14288 KB Output is correct
3 Correct 7 ms 14288 KB Output is correct
4 Correct 7 ms 14288 KB Output is correct
5 Correct 8 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 8 ms 14288 KB Output is correct
8 Correct 7 ms 14288 KB Output is correct
9 Correct 7 ms 14292 KB Output is correct
10 Correct 7 ms 14288 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 8 ms 14288 KB Output is correct
13 Correct 8 ms 14288 KB Output is correct
14 Correct 7 ms 14408 KB Output is correct
15 Correct 7 ms 14404 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 8 ms 14288 KB Output is correct
18 Correct 7 ms 14288 KB Output is correct
19 Correct 7 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 7 ms 14416 KB Output is correct
23 Correct 9 ms 14452 KB Output is correct
24 Correct 12 ms 14440 KB Output is correct
25 Correct 10 ms 14432 KB Output is correct
26 Correct 10 ms 14416 KB Output is correct
27 Correct 10 ms 14444 KB Output is correct
28 Correct 9 ms 14428 KB Output is correct
29 Correct 10 ms 14436 KB Output is correct
30 Correct 22 ms 15712 KB Output is correct
31 Correct 11 ms 15088 KB Output is correct
32 Correct 24 ms 16596 KB Output is correct
33 Correct 23 ms 16424 KB Output is correct
34 Correct 953 ms 17408 KB Output is correct
35 Correct 340 ms 16856 KB Output is correct
36 Correct 44 ms 16576 KB Output is correct
37 Correct 35 ms 16424 KB Output is correct
38 Correct 38 ms 16240 KB Output is correct
39 Correct 36 ms 16396 KB Output is correct
40 Correct 816 ms 17636 KB Output is correct
41 Correct 184 ms 16552 KB Output is correct
42 Correct 112 ms 16416 KB Output is correct
43 Correct 48 ms 17068 KB Output is correct
44 Correct 761 ms 17436 KB Output is correct
45 Correct 268 ms 28020 KB Output is correct
46 Correct 14 ms 17232 KB Output is correct
47 Correct 14 ms 17152 KB Output is correct
48 Correct 311 ms 39452 KB Output is correct
49 Correct 239 ms 35416 KB Output is correct
50 Execution timed out 4074 ms 40136 KB Time limit exceeded
51 Halted 0 ms 0 KB -