#include <bits/stdc++.h>
#include "game.h"
using namespace std;
const int MAX = 1550;
int n, pai[MAX], sze[MAX], f[MAX][MAX];
int find(int u){
return pai[u] = (pai[u] == u ? u : find(pai[u]));
}
void join(int u, int v){
u = find(u), v = find(v);
if(u == v) return;
if(sze[v] > sze[u]) swap(u, v);
pai[v] = u; sze[u] += sze[v];
for(int i = 1; i <= n; i++)
f[u][i] += f[v][i], f[i][u] += f[v][i];
}
void initialize(int _n){
n = _n;
for(int i = 1; i <= n; i++){
pai[i] = i; sze[i] = 1;
for(int j = i + 1; j <= n; j++)
f[i][j] = f[j][i] = 1;
}
}
int hasEdge(int u, int v){
u++, v++;
u = find(u), v = find(v);
if(u == v) return 0;
if(f[u][v] == 1){ join(u, v); return 1; }
f[u][v]--, f[v][u]--;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
312 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
316 KB |
Output is correct |
13 |
Correct |
0 ms |
312 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
312 KB |
Output is correct |
18 |
Correct |
0 ms |
312 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
308 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
312 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
312 KB |
Output is correct |
9 |
Correct |
0 ms |
316 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
316 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
320 KB |
Output is correct |
17 |
Correct |
0 ms |
328 KB |
Output is correct |
18 |
Correct |
1 ms |
352 KB |
Output is correct |
19 |
Correct |
1 ms |
352 KB |
Output is correct |
20 |
Correct |
1 ms |
352 KB |
Output is correct |
21 |
Correct |
0 ms |
352 KB |
Output is correct |
22 |
Correct |
1 ms |
320 KB |
Output is correct |
23 |
Correct |
1 ms |
324 KB |
Output is correct |
24 |
Correct |
0 ms |
352 KB |
Output is correct |
25 |
Correct |
1 ms |
480 KB |
Output is correct |
26 |
Correct |
1 ms |
480 KB |
Output is correct |
27 |
Correct |
1 ms |
480 KB |
Output is correct |
28 |
Correct |
1 ms |
480 KB |
Output is correct |
29 |
Correct |
1 ms |
480 KB |
Output is correct |
30 |
Correct |
1 ms |
480 KB |
Output is correct |
31 |
Correct |
1 ms |
480 KB |
Output is correct |
32 |
Correct |
1 ms |
480 KB |
Output is correct |
33 |
Correct |
1 ms |
480 KB |
Output is correct |
34 |
Correct |
1 ms |
608 KB |
Output is correct |
35 |
Correct |
2 ms |
608 KB |
Output is correct |
36 |
Correct |
2 ms |
724 KB |
Output is correct |
37 |
Correct |
1 ms |
724 KB |
Output is correct |
38 |
Correct |
2 ms |
608 KB |
Output is correct |
39 |
Correct |
1 ms |
608 KB |
Output is correct |
40 |
Correct |
1 ms |
608 KB |
Output is correct |
41 |
Correct |
2 ms |
608 KB |
Output is correct |
42 |
Correct |
2 ms |
608 KB |
Output is correct |
43 |
Correct |
1 ms |
716 KB |
Output is correct |
44 |
Correct |
1 ms |
720 KB |
Output is correct |
45 |
Correct |
1 ms |
716 KB |
Output is correct |
46 |
Correct |
1 ms |
716 KB |
Output is correct |
47 |
Correct |
1 ms |
608 KB |
Output is correct |
48 |
Correct |
1 ms |
608 KB |
Output is correct |
49 |
Correct |
2 ms |
608 KB |
Output is correct |
50 |
Correct |
1 ms |
608 KB |
Output is correct |
51 |
Correct |
1 ms |
608 KB |
Output is correct |
52 |
Correct |
1 ms |
716 KB |
Output is correct |
53 |
Correct |
1 ms |
708 KB |
Output is correct |
54 |
Correct |
1 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
308 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
312 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
312 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
308 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
312 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
440 KB |
Output is correct |
26 |
Correct |
1 ms |
580 KB |
Output is correct |
27 |
Correct |
1 ms |
440 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
712 KB |
Output is correct |
35 |
Correct |
1 ms |
596 KB |
Output is correct |
36 |
Correct |
1 ms |
596 KB |
Output is correct |
37 |
Correct |
1 ms |
596 KB |
Output is correct |
38 |
Correct |
2 ms |
596 KB |
Output is correct |
39 |
Correct |
1 ms |
596 KB |
Output is correct |
40 |
Correct |
1 ms |
596 KB |
Output is correct |
41 |
Correct |
1 ms |
596 KB |
Output is correct |
42 |
Correct |
2 ms |
700 KB |
Output is correct |
43 |
Correct |
1 ms |
700 KB |
Output is correct |
44 |
Correct |
1 ms |
596 KB |
Output is correct |
45 |
Correct |
1 ms |
596 KB |
Output is correct |
46 |
Correct |
1 ms |
720 KB |
Output is correct |
47 |
Correct |
1 ms |
596 KB |
Output is correct |
48 |
Correct |
1 ms |
596 KB |
Output is correct |
49 |
Correct |
1 ms |
596 KB |
Output is correct |
50 |
Correct |
2 ms |
596 KB |
Output is correct |
51 |
Correct |
1 ms |
596 KB |
Output is correct |
52 |
Correct |
1 ms |
596 KB |
Output is correct |
53 |
Correct |
2 ms |
596 KB |
Output is correct |
54 |
Correct |
1 ms |
708 KB |
Output is correct |
55 |
Correct |
40 ms |
5160 KB |
Output is correct |
56 |
Correct |
37 ms |
5116 KB |
Output is correct |
57 |
Correct |
38 ms |
5068 KB |
Output is correct |
58 |
Correct |
34 ms |
5188 KB |
Output is correct |
59 |
Correct |
34 ms |
5144 KB |
Output is correct |
60 |
Correct |
33 ms |
5048 KB |
Output is correct |
61 |
Correct |
34 ms |
5068 KB |
Output is correct |
62 |
Correct |
39 ms |
5096 KB |
Output is correct |
63 |
Correct |
36 ms |
5056 KB |
Output is correct |
64 |
Correct |
32 ms |
5068 KB |
Output is correct |
65 |
Correct |
34 ms |
5116 KB |
Output is correct |
66 |
Correct |
34 ms |
5064 KB |
Output is correct |
67 |
Correct |
37 ms |
5152 KB |
Output is correct |
68 |
Correct |
35 ms |
5068 KB |
Output is correct |
69 |
Correct |
36 ms |
5124 KB |
Output is correct |
70 |
Correct |
38 ms |
5064 KB |
Output is correct |
71 |
Correct |
33 ms |
5044 KB |
Output is correct |
72 |
Correct |
33 ms |
5076 KB |
Output is correct |
73 |
Correct |
32 ms |
5068 KB |
Output is correct |
74 |
Correct |
32 ms |
5088 KB |
Output is correct |
75 |
Correct |
33 ms |
5068 KB |
Output is correct |
76 |
Correct |
74 ms |
9036 KB |
Output is correct |
77 |
Correct |
85 ms |
9124 KB |
Output is correct |
78 |
Correct |
80 ms |
9012 KB |
Output is correct |
79 |
Correct |
80 ms |
8976 KB |
Output is correct |
80 |
Correct |
74 ms |
9012 KB |
Output is correct |
81 |
Correct |
90 ms |
8976 KB |
Output is correct |
82 |
Correct |
75 ms |
9056 KB |
Output is correct |
83 |
Correct |
82 ms |
9020 KB |
Output is correct |
84 |
Correct |
75 ms |
8984 KB |
Output is correct |
85 |
Correct |
143 ms |
13636 KB |
Output is correct |
86 |
Correct |
137 ms |
13676 KB |
Output is correct |
87 |
Correct |
132 ms |
13552 KB |
Output is correct |
88 |
Correct |
143 ms |
13628 KB |
Output is correct |
89 |
Correct |
136 ms |
13736 KB |
Output is correct |
90 |
Correct |
131 ms |
13516 KB |
Output is correct |
91 |
Correct |
145 ms |
13604 KB |
Output is correct |
92 |
Correct |
136 ms |
13740 KB |
Output is correct |
93 |
Correct |
141 ms |
13576 KB |
Output is correct |
94 |
Correct |
323 ms |
25424 KB |
Output is correct |
95 |
Correct |
348 ms |
25404 KB |
Output is correct |
96 |
Correct |
320 ms |
25396 KB |
Output is correct |
97 |
Correct |
322 ms |
25492 KB |
Output is correct |
98 |
Correct |
337 ms |
25308 KB |
Output is correct |
99 |
Correct |
325 ms |
25348 KB |
Output is correct |
100 |
Correct |
319 ms |
25380 KB |
Output is correct |