# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
707928 |
2023-03-10T14:09:22 Z |
speedyArda |
Game (IOI14_game) |
C++14 |
|
355 ms |
25240 KB |
#include "game.h"
#include "bits/stdc++.h"
using namespace std;
const int MAXN = 1505;
int par[MAXN];
int comp[MAXN][MAXN];
int n;
int find(int v)
{
if(par[v] == v)
return v;
return par[v] = find(par[v]);
}
void merge(int f, int s)
{
f = find(f), s = find(s);
if(f == s)
return;
if(f > s)
swap(f, s);
par[s] = f;
for(int i = 1; i <= n; i++)
{
if(i == f)
continue;
int old = comp[f][i];
comp[f][i] = old + comp[s][i];
comp[i][f] = old + comp[i][s];
}
}
void initialize(int total) {
n = total;
for(int i = 1; i <= n; i++)
{
par[i] = i;
for(int j = 1; j <= n; j++) {
comp[i][j] = (i != j ? 1 : 0);
//cout << i << " " << j << " " << comp[i][j] << "\n";
}
}
}
int hasEdge(int u, int v) {
u++;
v++;
if(comp[find(u)][find(v)] == 1) {
merge(u, v);
return 1;
}
else {
comp[find(u)][find(v)]--;
comp[find(v)][find(u)]--;
return 0;
}
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 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 |
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 |
1 ms |
212 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 |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
312 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 |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
308 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
304 KB |
Output is correct |
21 |
Correct |
0 ms |
308 KB |
Output is correct |
22 |
Correct |
1 ms |
308 KB |
Output is correct |
23 |
Correct |
0 ms |
304 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
304 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 |
304 KB |
Output is correct |
10 |
Correct |
1 ms |
308 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
304 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
304 KB |
Output is correct |
17 |
Correct |
1 ms |
304 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
304 KB |
Output is correct |
20 |
Correct |
1 ms |
312 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
304 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 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 |
596 KB |
Output is correct |
35 |
Correct |
1 ms |
596 KB |
Output is correct |
36 |
Correct |
2 ms |
704 KB |
Output is correct |
37 |
Correct |
1 ms |
700 KB |
Output is correct |
38 |
Correct |
1 ms |
704 KB |
Output is correct |
39 |
Correct |
2 ms |
696 KB |
Output is correct |
40 |
Correct |
2 ms |
596 KB |
Output is correct |
41 |
Correct |
1 ms |
596 KB |
Output is correct |
42 |
Correct |
2 ms |
708 KB |
Output is correct |
43 |
Correct |
1 ms |
596 KB |
Output is correct |
44 |
Correct |
1 ms |
704 KB |
Output is correct |
45 |
Correct |
1 ms |
596 KB |
Output is correct |
46 |
Correct |
2 ms |
596 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 |
1 ms |
700 KB |
Output is correct |
51 |
Correct |
2 ms |
704 KB |
Output is correct |
52 |
Correct |
1 ms |
596 KB |
Output is correct |
53 |
Correct |
1 ms |
596 KB |
Output is correct |
54 |
Correct |
1 ms |
700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
304 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
304 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
304 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
312 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
340 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 |
2 ms |
596 KB |
Output is correct |
35 |
Correct |
1 ms |
708 KB |
Output is correct |
36 |
Correct |
1 ms |
596 KB |
Output is correct |
37 |
Correct |
1 ms |
596 KB |
Output is correct |
38 |
Correct |
1 ms |
692 KB |
Output is correct |
39 |
Correct |
1 ms |
596 KB |
Output is correct |
40 |
Correct |
2 ms |
704 KB |
Output is correct |
41 |
Correct |
1 ms |
596 KB |
Output is correct |
42 |
Correct |
1 ms |
700 KB |
Output is correct |
43 |
Correct |
1 ms |
708 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 |
596 KB |
Output is correct |
47 |
Correct |
1 ms |
596 KB |
Output is correct |
48 |
Correct |
1 ms |
596 KB |
Output is correct |
49 |
Correct |
2 ms |
696 KB |
Output is correct |
50 |
Correct |
1 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 |
1 ms |
696 KB |
Output is correct |
54 |
Correct |
1 ms |
596 KB |
Output is correct |
55 |
Correct |
36 ms |
5032 KB |
Output is correct |
56 |
Correct |
34 ms |
5008 KB |
Output is correct |
57 |
Correct |
34 ms |
5008 KB |
Output is correct |
58 |
Correct |
36 ms |
5052 KB |
Output is correct |
59 |
Correct |
36 ms |
4972 KB |
Output is correct |
60 |
Correct |
43 ms |
5080 KB |
Output is correct |
61 |
Correct |
39 ms |
5092 KB |
Output is correct |
62 |
Correct |
33 ms |
4992 KB |
Output is correct |
63 |
Correct |
46 ms |
5068 KB |
Output is correct |
64 |
Correct |
36 ms |
5068 KB |
Output is correct |
65 |
Correct |
34 ms |
5076 KB |
Output is correct |
66 |
Correct |
41 ms |
5080 KB |
Output is correct |
67 |
Correct |
35 ms |
4984 KB |
Output is correct |
68 |
Correct |
34 ms |
5016 KB |
Output is correct |
69 |
Correct |
36 ms |
5068 KB |
Output is correct |
70 |
Correct |
43 ms |
5096 KB |
Output is correct |
71 |
Correct |
47 ms |
4968 KB |
Output is correct |
72 |
Correct |
33 ms |
5068 KB |
Output is correct |
73 |
Correct |
32 ms |
5040 KB |
Output is correct |
74 |
Correct |
34 ms |
5068 KB |
Output is correct |
75 |
Correct |
38 ms |
5104 KB |
Output is correct |
76 |
Correct |
88 ms |
8856 KB |
Output is correct |
77 |
Correct |
79 ms |
8904 KB |
Output is correct |
78 |
Correct |
78 ms |
8896 KB |
Output is correct |
79 |
Correct |
84 ms |
8888 KB |
Output is correct |
80 |
Correct |
76 ms |
8908 KB |
Output is correct |
81 |
Correct |
77 ms |
8860 KB |
Output is correct |
82 |
Correct |
78 ms |
8916 KB |
Output is correct |
83 |
Correct |
79 ms |
8944 KB |
Output is correct |
84 |
Correct |
84 ms |
8872 KB |
Output is correct |
85 |
Correct |
139 ms |
13392 KB |
Output is correct |
86 |
Correct |
182 ms |
13516 KB |
Output is correct |
87 |
Correct |
137 ms |
13368 KB |
Output is correct |
88 |
Correct |
143 ms |
13372 KB |
Output is correct |
89 |
Correct |
152 ms |
13336 KB |
Output is correct |
90 |
Correct |
148 ms |
13484 KB |
Output is correct |
91 |
Correct |
143 ms |
13388 KB |
Output is correct |
92 |
Correct |
163 ms |
13492 KB |
Output is correct |
93 |
Correct |
156 ms |
13396 KB |
Output is correct |
94 |
Correct |
342 ms |
25224 KB |
Output is correct |
95 |
Correct |
355 ms |
25240 KB |
Output is correct |
96 |
Correct |
335 ms |
25164 KB |
Output is correct |
97 |
Correct |
343 ms |
25116 KB |
Output is correct |
98 |
Correct |
339 ms |
25180 KB |
Output is correct |
99 |
Correct |
331 ms |
25080 KB |
Output is correct |
100 |
Correct |
337 ms |
25176 KB |
Output is correct |