답안 #838779

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
838779 2023-08-27T17:52:35 Z arbuzick 게임 (APIO22_game) C++17
60 / 100
4000 ms 38780 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

const int maxn = 3e5 + 5;

vector<int> g[maxn], _g[maxn];

int mink[maxn], maxk[maxn];

int n, k;

void init(int _n, int _k) {
    n = _n, k = _k;
    for (int i = 0; i + 1 < k; ++i) {
        g[i].push_back(i + 1);
        _g[i + 1].push_back(i);
    }
    for (int i = 0; i < k; ++i) {
        mink[i] = maxk[i] = i;
    }
    for (int i = k; i < n; ++i) {
        mink[i] = k;
        maxk[i] = -1;
    }
}

bool dfs_min(int v, int val) {
    if (mink[v] <= val || v < k) {
        return false;
    }
    mink[v] = val;
    if (mink[v] <= maxk[v]) {
        return true;
    }
    for (auto u : _g[v]) {
        if (dfs_min(u, val)) {
            return true;
        }
    }
    return false;
}

bool dfs_max(int v, int val) {
    if (maxk[v] >= val || v < k) {
        return false;
    }
    maxk[v] = val;
    if (mink[v] <= maxk[v]) {
        return true;
    }
    for (auto u : g[v]) {
        if (dfs_max(u, val)) {
            return true;
        }
    }
    return false;
}

int add_teleporter(int u, int v) {
    if (u == v && u < k) {
        return 1;
    }
    if (u > v && u < k) {
        return 1;
    }
    if (u < k && v < k) {
        return 0;
    }
    g[u].push_back(v);
    _g[v].push_back(u);
    return dfs_max(v, maxk[u]) || dfs_min(u, mink[v]);
}

// int main() {
//   int N, M, K;
//   cin >> N >> M >> K;
//   std::vector<int> u(M), v(M);
//   for (int i = 0; i < M; ++i) {
//       cin >> u[i] >> v[i];
//   }

//   init(N, K);
//   int i;
//   for (i = 0; i < M; ++i) {
//     int answer = add_teleporter(u[i], v[i]);
//     if (answer != 0 && answer != 1) {
//       i = -1;
//       break;
//     } else if (answer == 1) {
//       break;
//     }
//   }
//   cout << i;
//   return 0;
// }
# 결과 실행 시간 메모리 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 7 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 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 7 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 7 ms 14288 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 8 ms 14348 KB Output is correct
10 Correct 7 ms 14296 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 8 ms 14280 KB Output is correct
13 Correct 7 ms 14288 KB Output is correct
14 Correct 7 ms 14288 KB Output is correct
15 Correct 7 ms 14408 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 9 ms 14308 KB Output is correct
18 Correct 8 ms 14292 KB Output is correct
19 Correct 8 ms 14284 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 7 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 7 ms 14288 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 8 ms 14348 KB Output is correct
10 Correct 7 ms 14296 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 8 ms 14280 KB Output is correct
13 Correct 7 ms 14288 KB Output is correct
14 Correct 7 ms 14288 KB Output is correct
15 Correct 7 ms 14408 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 9 ms 14308 KB Output is correct
18 Correct 8 ms 14292 KB Output is correct
19 Correct 8 ms 14284 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14420 KB Output is correct
22 Correct 7 ms 14416 KB Output is correct
23 Correct 7 ms 14416 KB Output is correct
24 Correct 10 ms 14416 KB Output is correct
25 Correct 11 ms 14464 KB Output is correct
26 Correct 10 ms 14468 KB Output is correct
27 Correct 9 ms 14444 KB Output is correct
28 Correct 9 ms 14416 KB Output is correct
29 Correct 9 ms 14416 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 7 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 7 ms 14288 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 8 ms 14348 KB Output is correct
10 Correct 7 ms 14296 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 8 ms 14280 KB Output is correct
13 Correct 7 ms 14288 KB Output is correct
14 Correct 7 ms 14288 KB Output is correct
15 Correct 7 ms 14408 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 9 ms 14308 KB Output is correct
18 Correct 8 ms 14292 KB Output is correct
19 Correct 8 ms 14284 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14420 KB Output is correct
22 Correct 7 ms 14416 KB Output is correct
23 Correct 7 ms 14416 KB Output is correct
24 Correct 10 ms 14416 KB Output is correct
25 Correct 11 ms 14464 KB Output is correct
26 Correct 10 ms 14468 KB Output is correct
27 Correct 9 ms 14444 KB Output is correct
28 Correct 9 ms 14416 KB Output is correct
29 Correct 9 ms 14416 KB Output is correct
30 Correct 18 ms 15740 KB Output is correct
31 Correct 11 ms 15016 KB Output is correct
32 Correct 20 ms 16616 KB Output is correct
33 Correct 25 ms 16416 KB Output is correct
34 Correct 866 ms 17124 KB Output is correct
35 Correct 313 ms 16784 KB Output is correct
36 Correct 33 ms 16460 KB Output is correct
37 Correct 38 ms 16440 KB Output is correct
38 Correct 34 ms 16180 KB Output is correct
39 Correct 26 ms 16308 KB Output is correct
40 Correct 722 ms 17260 KB Output is correct
41 Correct 140 ms 16444 KB Output is correct
42 Correct 95 ms 16368 KB Output is correct
43 Correct 34 ms 16948 KB Output is correct
44 Correct 628 ms 17152 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 7 ms 14288 KB Output is correct
6 Correct 8 ms 14288 KB Output is correct
7 Correct 7 ms 14288 KB Output is correct
8 Correct 8 ms 14288 KB Output is correct
9 Correct 8 ms 14348 KB Output is correct
10 Correct 7 ms 14296 KB Output is correct
11 Correct 7 ms 14288 KB Output is correct
12 Correct 8 ms 14280 KB Output is correct
13 Correct 7 ms 14288 KB Output is correct
14 Correct 7 ms 14288 KB Output is correct
15 Correct 7 ms 14408 KB Output is correct
16 Correct 8 ms 14288 KB Output is correct
17 Correct 9 ms 14308 KB Output is correct
18 Correct 8 ms 14292 KB Output is correct
19 Correct 8 ms 14284 KB Output is correct
20 Correct 8 ms 14416 KB Output is correct
21 Correct 8 ms 14420 KB Output is correct
22 Correct 7 ms 14416 KB Output is correct
23 Correct 7 ms 14416 KB Output is correct
24 Correct 10 ms 14416 KB Output is correct
25 Correct 11 ms 14464 KB Output is correct
26 Correct 10 ms 14468 KB Output is correct
27 Correct 9 ms 14444 KB Output is correct
28 Correct 9 ms 14416 KB Output is correct
29 Correct 9 ms 14416 KB Output is correct
30 Correct 18 ms 15740 KB Output is correct
31 Correct 11 ms 15016 KB Output is correct
32 Correct 20 ms 16616 KB Output is correct
33 Correct 25 ms 16416 KB Output is correct
34 Correct 866 ms 17124 KB Output is correct
35 Correct 313 ms 16784 KB Output is correct
36 Correct 33 ms 16460 KB Output is correct
37 Correct 38 ms 16440 KB Output is correct
38 Correct 34 ms 16180 KB Output is correct
39 Correct 26 ms 16308 KB Output is correct
40 Correct 722 ms 17260 KB Output is correct
41 Correct 140 ms 16444 KB Output is correct
42 Correct 95 ms 16368 KB Output is correct
43 Correct 34 ms 16948 KB Output is correct
44 Correct 628 ms 17152 KB Output is correct
45 Correct 199 ms 28060 KB Output is correct
46 Correct 12 ms 17192 KB Output is correct
47 Correct 11 ms 17232 KB Output is correct
48 Correct 275 ms 38200 KB Output is correct
49 Correct 219 ms 35388 KB Output is correct
50 Execution timed out 4085 ms 38780 KB Time limit exceeded
51 Halted 0 ms 0 KB -