# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
489337 |
2021-11-22T14:20:49 Z |
Drew_ |
Game (IOI14_game) |
C++17 |
|
377 ms |
19712 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int, int>
constexpr int MAX = 1569;
int n;
int ds[MAX];
int ctr[MAX][MAX];
inline int frep(int x) { return ds[x] == x ? x : ds[x] = frep(ds[x]); }
inline void join(int x, int y)
{
x = frep(x); y = frep(y);
if (x == y)
return;
for (int i = 0; i < n; ++i)
{
if (i == x || i == y)
continue;
ctr[i][x] += ctr[i][y];
ctr[x][i] += ctr[y][i];
}
ds[y] = x;
}
void initialize(int N) {
n = N;
for (int i = 0; i < n; ++i)
ds[i] = i;
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
ctr[i][j] = 1;
}
int hasEdge(int u, int v) {
u = frep(u); v = frep(v);
if (ctr[u][v] > 1)
{
ctr[u][v]--; ctr[v][u]--;
return 0;
}
join(u, v);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
296 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
0 ms |
300 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
0 ms |
300 KB |
Output is correct |
23 |
Correct |
0 ms |
204 KB |
Output is correct |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
25 |
Correct |
0 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
432 KB |
Output is correct |
33 |
Correct |
1 ms |
332 KB |
Output is correct |
34 |
Correct |
1 ms |
588 KB |
Output is correct |
35 |
Correct |
1 ms |
696 KB |
Output is correct |
36 |
Correct |
1 ms |
588 KB |
Output is correct |
37 |
Correct |
1 ms |
588 KB |
Output is correct |
38 |
Correct |
1 ms |
588 KB |
Output is correct |
39 |
Correct |
1 ms |
588 KB |
Output is correct |
40 |
Correct |
1 ms |
588 KB |
Output is correct |
41 |
Correct |
1 ms |
588 KB |
Output is correct |
42 |
Correct |
1 ms |
588 KB |
Output is correct |
43 |
Correct |
1 ms |
588 KB |
Output is correct |
44 |
Correct |
1 ms |
588 KB |
Output is correct |
45 |
Correct |
1 ms |
588 KB |
Output is correct |
46 |
Correct |
1 ms |
692 KB |
Output is correct |
47 |
Correct |
2 ms |
700 KB |
Output is correct |
48 |
Correct |
1 ms |
700 KB |
Output is correct |
49 |
Correct |
1 ms |
692 KB |
Output is correct |
50 |
Correct |
1 ms |
588 KB |
Output is correct |
51 |
Correct |
1 ms |
588 KB |
Output is correct |
52 |
Correct |
1 ms |
588 KB |
Output is correct |
53 |
Correct |
1 ms |
700 KB |
Output is correct |
54 |
Correct |
1 ms |
696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
296 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
304 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
0 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
424 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
332 KB |
Output is correct |
33 |
Correct |
1 ms |
460 KB |
Output is correct |
34 |
Correct |
1 ms |
588 KB |
Output is correct |
35 |
Correct |
1 ms |
588 KB |
Output is correct |
36 |
Correct |
1 ms |
588 KB |
Output is correct |
37 |
Correct |
1 ms |
588 KB |
Output is correct |
38 |
Correct |
2 ms |
588 KB |
Output is correct |
39 |
Correct |
1 ms |
588 KB |
Output is correct |
40 |
Correct |
1 ms |
588 KB |
Output is correct |
41 |
Correct |
1 ms |
588 KB |
Output is correct |
42 |
Correct |
1 ms |
696 KB |
Output is correct |
43 |
Correct |
1 ms |
588 KB |
Output is correct |
44 |
Correct |
1 ms |
692 KB |
Output is correct |
45 |
Correct |
1 ms |
696 KB |
Output is correct |
46 |
Correct |
1 ms |
588 KB |
Output is correct |
47 |
Correct |
1 ms |
588 KB |
Output is correct |
48 |
Correct |
1 ms |
588 KB |
Output is correct |
49 |
Correct |
2 ms |
700 KB |
Output is correct |
50 |
Correct |
2 ms |
588 KB |
Output is correct |
51 |
Correct |
1 ms |
588 KB |
Output is correct |
52 |
Correct |
1 ms |
588 KB |
Output is correct |
53 |
Correct |
1 ms |
588 KB |
Output is correct |
54 |
Correct |
1 ms |
588 KB |
Output is correct |
55 |
Correct |
38 ms |
4912 KB |
Output is correct |
56 |
Correct |
32 ms |
4908 KB |
Output is correct |
57 |
Correct |
34 ms |
4932 KB |
Output is correct |
58 |
Correct |
35 ms |
4904 KB |
Output is correct |
59 |
Correct |
35 ms |
4996 KB |
Output is correct |
60 |
Correct |
35 ms |
4932 KB |
Output is correct |
61 |
Correct |
33 ms |
4932 KB |
Output is correct |
62 |
Correct |
32 ms |
4912 KB |
Output is correct |
63 |
Correct |
33 ms |
4972 KB |
Output is correct |
64 |
Correct |
34 ms |
4992 KB |
Output is correct |
65 |
Correct |
32 ms |
4912 KB |
Output is correct |
66 |
Correct |
46 ms |
4948 KB |
Output is correct |
67 |
Correct |
35 ms |
4988 KB |
Output is correct |
68 |
Correct |
34 ms |
4984 KB |
Output is correct |
69 |
Correct |
33 ms |
4916 KB |
Output is correct |
70 |
Correct |
33 ms |
4904 KB |
Output is correct |
71 |
Correct |
35 ms |
5000 KB |
Output is correct |
72 |
Correct |
33 ms |
4932 KB |
Output is correct |
73 |
Correct |
31 ms |
4992 KB |
Output is correct |
74 |
Correct |
33 ms |
4920 KB |
Output is correct |
75 |
Correct |
33 ms |
4932 KB |
Output is correct |
76 |
Correct |
76 ms |
8700 KB |
Output is correct |
77 |
Correct |
82 ms |
8708 KB |
Output is correct |
78 |
Correct |
82 ms |
8816 KB |
Output is correct |
79 |
Correct |
81 ms |
8740 KB |
Output is correct |
80 |
Correct |
78 ms |
8744 KB |
Output is correct |
81 |
Correct |
76 ms |
8772 KB |
Output is correct |
82 |
Correct |
78 ms |
8696 KB |
Output is correct |
83 |
Correct |
76 ms |
8752 KB |
Output is correct |
84 |
Correct |
75 ms |
8804 KB |
Output is correct |
85 |
Correct |
140 ms |
11588 KB |
Output is correct |
86 |
Correct |
143 ms |
11620 KB |
Output is correct |
87 |
Correct |
151 ms |
11532 KB |
Output is correct |
88 |
Correct |
139 ms |
11540 KB |
Output is correct |
89 |
Correct |
151 ms |
11560 KB |
Output is correct |
90 |
Correct |
148 ms |
11636 KB |
Output is correct |
91 |
Correct |
181 ms |
11776 KB |
Output is correct |
92 |
Correct |
141 ms |
11588 KB |
Output is correct |
93 |
Correct |
142 ms |
11716 KB |
Output is correct |
94 |
Correct |
332 ms |
19636 KB |
Output is correct |
95 |
Correct |
362 ms |
19536 KB |
Output is correct |
96 |
Correct |
377 ms |
19616 KB |
Output is correct |
97 |
Correct |
344 ms |
19708 KB |
Output is correct |
98 |
Correct |
357 ms |
19712 KB |
Output is correct |
99 |
Correct |
346 ms |
19696 KB |
Output is correct |
100 |
Correct |
324 ms |
19544 KB |
Output is correct |