답안 #622844

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
622844 2022-08-04T16:31:42 Z yuto1115 게임 (IOI14_game) C++17
100 / 100
616 ms 25188 KB
#include "game.h"
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, s, n) for(ll i = ll(s); i < ll(n); ++i)
#define rrep(i, n) for(ll i = ll(n) - 1; i >= 0; --i)
#define rrep2(i, n, t) for(ll i = ll(n) - 1; i >= ll(t); --i)
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define SZ(a) int(a.size())
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<P>;
using vvp = vector<vp>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;
const int inf = 1001001001;
const ll linf = 1001001001001001001;

template<class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int n;

vi r;
vb is_r;
vvi cnt;

void initialize(int N) {
    n = N;
    r.resize(n);
    iota(all(r), 0);
    is_r.assign(n, true);
    cnt.assign(n, vi(n, 1));
}

int hasEdge(int u, int v) {
    u = r[u];
    v = r[v];
    assert(u != v);
    if (cnt[u][v] > 1) {
        --cnt[u][v];
        --cnt[v][u];
        return 0;
    } else {
        rep(i, n) if (r[i] == v) r[i] = u;
        is_r[v] = false;
        rep(i, n) {
            if (is_r[i] and i != u) {
                cnt[i][u] = cnt[u][i] += cnt[v][i];
            }
        }
        return 1;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 4 ms 312 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 312 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 4 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 4 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
29 Correct 4 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 5 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 11 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 10 ms 372 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 320 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 2 ms 340 KB Output is correct
43 Correct 2 ms 340 KB Output is correct
44 Correct 2 ms 356 KB Output is correct
45 Correct 2 ms 340 KB Output is correct
46 Correct 2 ms 320 KB Output is correct
47 Correct 2 ms 364 KB Output is correct
48 Correct 2 ms 340 KB Output is correct
49 Correct 2 ms 340 KB Output is correct
50 Correct 2 ms 316 KB Output is correct
51 Correct 2 ms 356 KB Output is correct
52 Correct 1 ms 320 KB Output is correct
53 Correct 8 ms 340 KB Output is correct
54 Correct 2 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 304 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 308 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 308 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 292 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 2 ms 348 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 2 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 2 ms 316 KB Output is correct
42 Correct 2 ms 316 KB Output is correct
43 Correct 2 ms 320 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 3 ms 372 KB Output is correct
46 Correct 2 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 320 KB Output is correct
49 Correct 2 ms 312 KB Output is correct
50 Correct 2 ms 340 KB Output is correct
51 Correct 3 ms 340 KB Output is correct
52 Correct 2 ms 320 KB Output is correct
53 Correct 2 ms 320 KB Output is correct
54 Correct 2 ms 340 KB Output is correct
55 Correct 60 ms 3084 KB Output is correct
56 Correct 37 ms 3048 KB Output is correct
57 Correct 35 ms 3076 KB Output is correct
58 Correct 49 ms 3052 KB Output is correct
59 Correct 90 ms 3008 KB Output is correct
60 Correct 48 ms 3012 KB Output is correct
61 Correct 38 ms 2984 KB Output is correct
62 Correct 36 ms 3028 KB Output is correct
63 Correct 36 ms 3100 KB Output is correct
64 Correct 37 ms 3056 KB Output is correct
65 Correct 33 ms 3052 KB Output is correct
66 Correct 40 ms 3084 KB Output is correct
67 Correct 51 ms 3044 KB Output is correct
68 Correct 58 ms 3032 KB Output is correct
69 Correct 50 ms 2984 KB Output is correct
70 Correct 57 ms 3096 KB Output is correct
71 Correct 55 ms 3100 KB Output is correct
72 Correct 33 ms 3024 KB Output is correct
73 Correct 37 ms 3100 KB Output is correct
74 Correct 49 ms 2980 KB Output is correct
75 Correct 58 ms 2980 KB Output is correct
76 Correct 105 ms 6732 KB Output is correct
77 Correct 89 ms 6704 KB Output is correct
78 Correct 85 ms 6732 KB Output is correct
79 Correct 76 ms 6656 KB Output is correct
80 Correct 84 ms 6660 KB Output is correct
81 Correct 100 ms 6696 KB Output is correct
82 Correct 329 ms 6676 KB Output is correct
83 Correct 86 ms 6644 KB Output is correct
84 Correct 80 ms 6696 KB Output is correct
85 Correct 207 ms 11496 KB Output is correct
86 Correct 159 ms 11420 KB Output is correct
87 Correct 240 ms 11500 KB Output is correct
88 Correct 255 ms 11516 KB Output is correct
89 Correct 164 ms 11468 KB Output is correct
90 Correct 188 ms 11512 KB Output is correct
91 Correct 154 ms 11496 KB Output is correct
92 Correct 172 ms 11428 KB Output is correct
93 Correct 147 ms 11476 KB Output is correct
94 Correct 445 ms 25188 KB Output is correct
95 Correct 495 ms 25084 KB Output is correct
96 Correct 383 ms 25120 KB Output is correct
97 Correct 502 ms 25128 KB Output is correct
98 Correct 434 ms 25156 KB Output is correct
99 Correct 616 ms 25164 KB Output is correct
100 Correct 353 ms 25132 KB Output is correct