Submission #1067595

# Submission time Handle Problem Language Result Execution time Memory
1067595 2024-08-20T20:59:10 Z beaconmc Game (IOI14_game) C++14
100 / 100
225 ms 34644 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
 


ll paths[1502][1502];
ll N = 0;

ll cmp[1502];

ll find(ll a){
    while (a != cmp[a]){
        cmp[a] = cmp[cmp[a]];
        a = cmp[a];
    }
    return a;
}


void unite(ll a, ll b){
    ll A = find(a);
    ll B = find(b);
    cmp[A] = B;



    FOR(i,0,1502){
        paths[B][i] += paths[A][i];
        paths[i][B] += paths[A][i];
    }

}

void initialize(int n){
    FOR(i,0,1502) cmp[i] = i;
    FOR(i,0,1502) FOR(j,0,1502) paths[i][j] = 1;
}
int hasEdge(int u, int v){
    ll U = find(u);
    ll V = find(v);

    paths[U][V]--;
    paths[V][U]--;



    if (paths[U][V] == 0){
        unite(u, v);
        return 1;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 19032 KB Output is correct
2 Correct 4 ms 19032 KB Output is correct
3 Correct 3 ms 19080 KB Output is correct
4 Correct 4 ms 19036 KB Output is correct
5 Correct 3 ms 19036 KB Output is correct
6 Correct 3 ms 19032 KB Output is correct
7 Correct 3 ms 19036 KB Output is correct
8 Correct 3 ms 19036 KB Output is correct
9 Correct 4 ms 19036 KB Output is correct
10 Correct 3 ms 19036 KB Output is correct
11 Correct 3 ms 19036 KB Output is correct
12 Correct 4 ms 19036 KB Output is correct
13 Correct 4 ms 18076 KB Output is correct
14 Correct 3 ms 19032 KB Output is correct
15 Correct 4 ms 18012 KB Output is correct
16 Correct 4 ms 18012 KB Output is correct
17 Correct 8 ms 18012 KB Output is correct
18 Correct 3 ms 19032 KB Output is correct
19 Correct 5 ms 19036 KB Output is correct
20 Correct 4 ms 19084 KB Output is correct
21 Correct 3 ms 19036 KB Output is correct
22 Correct 4 ms 19036 KB Output is correct
23 Correct 3 ms 19056 KB Output is correct
24 Correct 4 ms 19036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 18012 KB Output is correct
2 Correct 4 ms 19048 KB Output is correct
3 Correct 4 ms 18012 KB Output is correct
4 Correct 4 ms 18012 KB Output is correct
5 Correct 4 ms 18012 KB Output is correct
6 Correct 4 ms 18012 KB Output is correct
7 Correct 4 ms 18012 KB Output is correct
8 Correct 4 ms 18012 KB Output is correct
9 Correct 5 ms 18012 KB Output is correct
10 Correct 5 ms 18012 KB Output is correct
11 Correct 4 ms 18012 KB Output is correct
12 Correct 5 ms 19056 KB Output is correct
13 Correct 3 ms 19036 KB Output is correct
14 Correct 4 ms 19032 KB Output is correct
15 Correct 6 ms 19324 KB Output is correct
16 Correct 4 ms 19036 KB Output is correct
17 Correct 3 ms 19032 KB Output is correct
18 Correct 4 ms 19036 KB Output is correct
19 Correct 4 ms 19036 KB Output is correct
20 Correct 3 ms 19036 KB Output is correct
21 Correct 3 ms 19036 KB Output is correct
22 Correct 3 ms 19056 KB Output is correct
23 Correct 5 ms 19036 KB Output is correct
24 Correct 3 ms 19036 KB Output is correct
25 Correct 5 ms 18036 KB Output is correct
26 Correct 4 ms 18008 KB Output is correct
27 Correct 5 ms 18052 KB Output is correct
28 Correct 5 ms 18008 KB Output is correct
29 Correct 5 ms 18012 KB Output is correct
30 Correct 4 ms 19036 KB Output is correct
31 Correct 3 ms 19036 KB Output is correct
32 Correct 3 ms 19076 KB Output is correct
33 Correct 4 ms 18012 KB Output is correct
34 Correct 4 ms 19088 KB Output is correct
35 Correct 5 ms 18008 KB Output is correct
36 Correct 4 ms 18012 KB Output is correct
37 Correct 4 ms 18028 KB Output is correct
38 Correct 6 ms 18012 KB Output is correct
39 Correct 4 ms 18012 KB Output is correct
40 Correct 4 ms 18012 KB Output is correct
41 Correct 5 ms 18012 KB Output is correct
42 Correct 4 ms 19036 KB Output is correct
43 Correct 5 ms 18012 KB Output is correct
44 Correct 4 ms 18012 KB Output is correct
45 Correct 4 ms 19036 KB Output is correct
46 Correct 4 ms 19036 KB Output is correct
47 Correct 4 ms 19064 KB Output is correct
48 Correct 4 ms 19036 KB Output is correct
49 Correct 5 ms 18012 KB Output is correct
50 Correct 4 ms 19032 KB Output is correct
51 Correct 4 ms 19036 KB Output is correct
52 Correct 5 ms 17908 KB Output is correct
53 Correct 4 ms 19036 KB Output is correct
54 Correct 4 ms 19036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 18260 KB Output is correct
2 Correct 3 ms 19036 KB Output is correct
3 Correct 3 ms 18844 KB Output is correct
4 Correct 3 ms 19036 KB Output is correct
5 Correct 3 ms 19036 KB Output is correct
6 Correct 3 ms 19036 KB Output is correct
7 Correct 3 ms 19036 KB Output is correct
8 Correct 3 ms 19032 KB Output is correct
9 Correct 3 ms 19036 KB Output is correct
10 Correct 3 ms 19036 KB Output is correct
11 Correct 4 ms 19092 KB Output is correct
12 Correct 5 ms 19032 KB Output is correct
13 Correct 3 ms 19036 KB Output is correct
14 Correct 3 ms 19060 KB Output is correct
15 Correct 4 ms 19036 KB Output is correct
16 Correct 3 ms 19036 KB Output is correct
17 Correct 5 ms 19036 KB Output is correct
18 Correct 3 ms 19036 KB Output is correct
19 Correct 3 ms 19036 KB Output is correct
20 Correct 4 ms 19032 KB Output is correct
21 Correct 4 ms 19032 KB Output is correct
22 Correct 3 ms 19032 KB Output is correct
23 Correct 3 ms 19032 KB Output is correct
24 Correct 5 ms 19068 KB Output is correct
25 Correct 4 ms 19036 KB Output is correct
26 Correct 4 ms 19036 KB Output is correct
27 Correct 4 ms 19072 KB Output is correct
28 Correct 4 ms 19036 KB Output is correct
29 Correct 4 ms 18088 KB Output is correct
30 Correct 5 ms 18012 KB Output is correct
31 Correct 4 ms 18012 KB Output is correct
32 Correct 5 ms 18028 KB Output is correct
33 Correct 4 ms 18048 KB Output is correct
34 Correct 6 ms 18048 KB Output is correct
35 Correct 4 ms 19036 KB Output is correct
36 Correct 4 ms 19036 KB Output is correct
37 Correct 4 ms 19084 KB Output is correct
38 Correct 5 ms 18012 KB Output is correct
39 Correct 4 ms 19036 KB Output is correct
40 Correct 4 ms 19036 KB Output is correct
41 Correct 4 ms 19036 KB Output is correct
42 Correct 4 ms 19088 KB Output is correct
43 Correct 4 ms 19072 KB Output is correct
44 Correct 4 ms 19036 KB Output is correct
45 Correct 6 ms 19036 KB Output is correct
46 Correct 4 ms 19036 KB Output is correct
47 Correct 7 ms 18012 KB Output is correct
48 Correct 4 ms 18052 KB Output is correct
49 Correct 4 ms 18052 KB Output is correct
50 Correct 6 ms 18012 KB Output is correct
51 Correct 6 ms 18012 KB Output is correct
52 Correct 5 ms 18008 KB Output is correct
53 Correct 4 ms 19036 KB Output is correct
54 Correct 4 ms 19036 KB Output is correct
55 Correct 27 ms 19084 KB Output is correct
56 Correct 27 ms 19344 KB Output is correct
57 Correct 26 ms 19284 KB Output is correct
58 Correct 26 ms 19292 KB Output is correct
59 Correct 27 ms 19340 KB Output is correct
60 Correct 26 ms 19280 KB Output is correct
61 Correct 27 ms 19280 KB Output is correct
62 Correct 26 ms 19280 KB Output is correct
63 Correct 39 ms 19536 KB Output is correct
64 Correct 24 ms 19348 KB Output is correct
65 Correct 23 ms 19292 KB Output is correct
66 Correct 28 ms 19292 KB Output is correct
67 Correct 26 ms 19284 KB Output is correct
68 Correct 27 ms 19288 KB Output is correct
69 Correct 26 ms 19332 KB Output is correct
70 Correct 27 ms 19284 KB Output is correct
71 Correct 28 ms 19280 KB Output is correct
72 Correct 25 ms 19292 KB Output is correct
73 Correct 26 ms 19280 KB Output is correct
74 Correct 26 ms 19080 KB Output is correct
75 Correct 33 ms 19540 KB Output is correct
76 Correct 54 ms 21588 KB Output is correct
77 Correct 56 ms 21584 KB Output is correct
78 Correct 56 ms 21584 KB Output is correct
79 Correct 57 ms 21588 KB Output is correct
80 Correct 55 ms 21588 KB Output is correct
81 Correct 59 ms 21588 KB Output is correct
82 Correct 55 ms 21588 KB Output is correct
83 Correct 55 ms 21584 KB Output is correct
84 Correct 55 ms 21636 KB Output is correct
85 Correct 92 ms 22100 KB Output is correct
86 Correct 92 ms 22400 KB Output is correct
87 Correct 93 ms 22100 KB Output is correct
88 Correct 93 ms 22140 KB Output is correct
89 Correct 95 ms 22152 KB Output is correct
90 Correct 93 ms 22096 KB Output is correct
91 Correct 93 ms 22100 KB Output is correct
92 Correct 94 ms 22148 KB Output is correct
93 Correct 101 ms 22140 KB Output is correct
94 Correct 211 ms 25424 KB Output is correct
95 Correct 217 ms 34644 KB Output is correct
96 Correct 215 ms 34640 KB Output is correct
97 Correct 213 ms 34552 KB Output is correct
98 Correct 216 ms 34552 KB Output is correct
99 Correct 225 ms 34552 KB Output is correct
100 Correct 211 ms 34644 KB Output is correct