# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
431626 |
2021-06-17T13:49:12 Z |
rainboy |
Simurgh (IOI17_simurgh) |
C++ |
|
210 ms |
3404 KB |
#include "simurgh.h"
#include <string.h>
using namespace std;
#define N 240
#define M (N * (N - 1) / 2)
typedef vector<int> vi;
int ds[N];
int find(int i) {
return ds[i] < 0 ? i : (ds[i] = find(ds[i]));
}
int join(int i, int j) {
i = find(i);
j = find(j);
if (i == j)
return 0;
if (ds[i] > ds[j])
ds[i] = j;
else {
if (ds[i] == ds[j])
ds[i]--;
ds[j] = i;
}
return 1;
}
char cc[M]; int qu[M], cnt;
vi find_roads(int n, vi ii, vi jj) {
int m = ii.size(), m_, g, h, h_, k, k_;
vi hh(n - 1);
memset(cc, -1, m * sizeof *cc);
while (1) {
memset(ds, -1, n * sizeof *ds);
m_ = 0;
for (h = 0; h < m; h++)
if (cc[h] == 1)
join(ii[h], jj[h]), hh[m_++] = h;
if (m_ == n - 1)
break;
g = m_;
for (h = 0; h < m; h++)
if (cc[h] == -1 && join(ii[h], jj[h]))
hh[m_++] = h;
k = count_common_roads(hh);
memset(ds, -1, n * sizeof *ds);
for (h = 0; h < n - 1; h++)
if (h != g)
join(ii[hh[h]], jj[hh[h]]);
h_ = hh[g];
cnt = 0, qu[cnt++] = h_;
for (h = 0; h < m; h++)
if (cc[h] == -1 && h != h_ && find(ii[h]) != find(jj[h])) {
hh[g] = h;
k_ = count_common_roads(hh);
if (k_ == k + 1) {
while (cnt--)
cc[qu[cnt]] = 0;
cc[h] = 1;
break;
} else if (k_ == k - 1) {
while (cnt--)
cc[qu[cnt]] = 1;
cc[h] = 0;
break;
}
qu[cnt++] = h;
}
if (cnt > 0)
while (cnt--)
cc[qu[cnt]] = 1;
}
return hh;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
correct |
2 |
Correct |
1 ms |
280 KB |
correct |
3 |
Correct |
0 ms |
204 KB |
correct |
4 |
Correct |
0 ms |
204 KB |
correct |
5 |
Correct |
1 ms |
204 KB |
correct |
6 |
Correct |
0 ms |
204 KB |
correct |
7 |
Correct |
1 ms |
204 KB |
correct |
8 |
Correct |
0 ms |
204 KB |
correct |
9 |
Correct |
0 ms |
204 KB |
correct |
10 |
Correct |
1 ms |
204 KB |
correct |
11 |
Correct |
0 ms |
280 KB |
correct |
12 |
Correct |
1 ms |
204 KB |
correct |
13 |
Correct |
1 ms |
204 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
correct |
2 |
Correct |
1 ms |
280 KB |
correct |
3 |
Correct |
0 ms |
204 KB |
correct |
4 |
Correct |
0 ms |
204 KB |
correct |
5 |
Correct |
1 ms |
204 KB |
correct |
6 |
Correct |
0 ms |
204 KB |
correct |
7 |
Correct |
1 ms |
204 KB |
correct |
8 |
Correct |
0 ms |
204 KB |
correct |
9 |
Correct |
0 ms |
204 KB |
correct |
10 |
Correct |
1 ms |
204 KB |
correct |
11 |
Correct |
0 ms |
280 KB |
correct |
12 |
Correct |
1 ms |
204 KB |
correct |
13 |
Correct |
1 ms |
204 KB |
correct |
14 |
Correct |
2 ms |
204 KB |
correct |
15 |
Correct |
3 ms |
204 KB |
correct |
16 |
Correct |
4 ms |
268 KB |
correct |
17 |
Correct |
3 ms |
204 KB |
correct |
18 |
Correct |
1 ms |
204 KB |
correct |
19 |
Correct |
2 ms |
204 KB |
correct |
20 |
Correct |
2 ms |
224 KB |
correct |
21 |
Correct |
2 ms |
204 KB |
correct |
22 |
Correct |
1 ms |
204 KB |
correct |
23 |
Correct |
1 ms |
204 KB |
correct |
24 |
Correct |
1 ms |
204 KB |
correct |
25 |
Correct |
1 ms |
204 KB |
correct |
26 |
Correct |
1 ms |
280 KB |
correct |
27 |
Correct |
1 ms |
204 KB |
correct |
28 |
Correct |
1 ms |
292 KB |
correct |
29 |
Correct |
1 ms |
204 KB |
correct |
30 |
Correct |
1 ms |
204 KB |
correct |
31 |
Correct |
1 ms |
204 KB |
correct |
32 |
Correct |
1 ms |
204 KB |
correct |
33 |
Correct |
1 ms |
204 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
correct |
2 |
Correct |
1 ms |
280 KB |
correct |
3 |
Correct |
0 ms |
204 KB |
correct |
4 |
Correct |
0 ms |
204 KB |
correct |
5 |
Correct |
1 ms |
204 KB |
correct |
6 |
Correct |
0 ms |
204 KB |
correct |
7 |
Correct |
1 ms |
204 KB |
correct |
8 |
Correct |
0 ms |
204 KB |
correct |
9 |
Correct |
0 ms |
204 KB |
correct |
10 |
Correct |
1 ms |
204 KB |
correct |
11 |
Correct |
0 ms |
280 KB |
correct |
12 |
Correct |
1 ms |
204 KB |
correct |
13 |
Correct |
1 ms |
204 KB |
correct |
14 |
Correct |
2 ms |
204 KB |
correct |
15 |
Correct |
3 ms |
204 KB |
correct |
16 |
Correct |
4 ms |
268 KB |
correct |
17 |
Correct |
3 ms |
204 KB |
correct |
18 |
Correct |
1 ms |
204 KB |
correct |
19 |
Correct |
2 ms |
204 KB |
correct |
20 |
Correct |
2 ms |
224 KB |
correct |
21 |
Correct |
2 ms |
204 KB |
correct |
22 |
Correct |
1 ms |
204 KB |
correct |
23 |
Correct |
1 ms |
204 KB |
correct |
24 |
Correct |
1 ms |
204 KB |
correct |
25 |
Correct |
1 ms |
204 KB |
correct |
26 |
Correct |
1 ms |
280 KB |
correct |
27 |
Correct |
1 ms |
204 KB |
correct |
28 |
Correct |
1 ms |
292 KB |
correct |
29 |
Correct |
1 ms |
204 KB |
correct |
30 |
Correct |
1 ms |
204 KB |
correct |
31 |
Correct |
1 ms |
204 KB |
correct |
32 |
Correct |
1 ms |
204 KB |
correct |
33 |
Correct |
1 ms |
204 KB |
correct |
34 |
Correct |
201 ms |
848 KB |
correct |
35 |
Correct |
203 ms |
872 KB |
correct |
36 |
Correct |
138 ms |
588 KB |
correct |
37 |
Correct |
12 ms |
204 KB |
correct |
38 |
Correct |
205 ms |
892 KB |
correct |
39 |
Correct |
183 ms |
716 KB |
correct |
40 |
Correct |
142 ms |
588 KB |
correct |
41 |
Correct |
190 ms |
888 KB |
correct |
42 |
Correct |
210 ms |
892 KB |
correct |
43 |
Correct |
37 ms |
556 KB |
correct |
44 |
Correct |
31 ms |
552 KB |
correct |
45 |
Correct |
33 ms |
516 KB |
correct |
46 |
Correct |
28 ms |
540 KB |
correct |
47 |
Correct |
18 ms |
332 KB |
correct |
48 |
Correct |
5 ms |
204 KB |
correct |
49 |
Correct |
8 ms |
204 KB |
correct |
50 |
Correct |
15 ms |
392 KB |
correct |
51 |
Correct |
42 ms |
588 KB |
correct |
52 |
Correct |
32 ms |
452 KB |
correct |
53 |
Correct |
29 ms |
504 KB |
correct |
54 |
Correct |
35 ms |
588 KB |
correct |
55 |
Correct |
33 ms |
588 KB |
correct |
56 |
Correct |
33 ms |
588 KB |
correct |
57 |
Correct |
35 ms |
608 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
correct |
2 |
Correct |
0 ms |
204 KB |
correct |
3 |
Runtime error |
25 ms |
3404 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
correct |
2 |
Correct |
1 ms |
280 KB |
correct |
3 |
Correct |
0 ms |
204 KB |
correct |
4 |
Correct |
0 ms |
204 KB |
correct |
5 |
Correct |
1 ms |
204 KB |
correct |
6 |
Correct |
0 ms |
204 KB |
correct |
7 |
Correct |
1 ms |
204 KB |
correct |
8 |
Correct |
0 ms |
204 KB |
correct |
9 |
Correct |
0 ms |
204 KB |
correct |
10 |
Correct |
1 ms |
204 KB |
correct |
11 |
Correct |
0 ms |
280 KB |
correct |
12 |
Correct |
1 ms |
204 KB |
correct |
13 |
Correct |
1 ms |
204 KB |
correct |
14 |
Correct |
2 ms |
204 KB |
correct |
15 |
Correct |
3 ms |
204 KB |
correct |
16 |
Correct |
4 ms |
268 KB |
correct |
17 |
Correct |
3 ms |
204 KB |
correct |
18 |
Correct |
1 ms |
204 KB |
correct |
19 |
Correct |
2 ms |
204 KB |
correct |
20 |
Correct |
2 ms |
224 KB |
correct |
21 |
Correct |
2 ms |
204 KB |
correct |
22 |
Correct |
1 ms |
204 KB |
correct |
23 |
Correct |
1 ms |
204 KB |
correct |
24 |
Correct |
1 ms |
204 KB |
correct |
25 |
Correct |
1 ms |
204 KB |
correct |
26 |
Correct |
1 ms |
280 KB |
correct |
27 |
Correct |
1 ms |
204 KB |
correct |
28 |
Correct |
1 ms |
292 KB |
correct |
29 |
Correct |
1 ms |
204 KB |
correct |
30 |
Correct |
1 ms |
204 KB |
correct |
31 |
Correct |
1 ms |
204 KB |
correct |
32 |
Correct |
1 ms |
204 KB |
correct |
33 |
Correct |
1 ms |
204 KB |
correct |
34 |
Correct |
201 ms |
848 KB |
correct |
35 |
Correct |
203 ms |
872 KB |
correct |
36 |
Correct |
138 ms |
588 KB |
correct |
37 |
Correct |
12 ms |
204 KB |
correct |
38 |
Correct |
205 ms |
892 KB |
correct |
39 |
Correct |
183 ms |
716 KB |
correct |
40 |
Correct |
142 ms |
588 KB |
correct |
41 |
Correct |
190 ms |
888 KB |
correct |
42 |
Correct |
210 ms |
892 KB |
correct |
43 |
Correct |
37 ms |
556 KB |
correct |
44 |
Correct |
31 ms |
552 KB |
correct |
45 |
Correct |
33 ms |
516 KB |
correct |
46 |
Correct |
28 ms |
540 KB |
correct |
47 |
Correct |
18 ms |
332 KB |
correct |
48 |
Correct |
5 ms |
204 KB |
correct |
49 |
Correct |
8 ms |
204 KB |
correct |
50 |
Correct |
15 ms |
392 KB |
correct |
51 |
Correct |
42 ms |
588 KB |
correct |
52 |
Correct |
32 ms |
452 KB |
correct |
53 |
Correct |
29 ms |
504 KB |
correct |
54 |
Correct |
35 ms |
588 KB |
correct |
55 |
Correct |
33 ms |
588 KB |
correct |
56 |
Correct |
33 ms |
588 KB |
correct |
57 |
Correct |
35 ms |
608 KB |
correct |
58 |
Correct |
1 ms |
204 KB |
correct |
59 |
Correct |
0 ms |
204 KB |
correct |
60 |
Runtime error |
25 ms |
3404 KB |
Execution killed with signal 6 |
61 |
Halted |
0 ms |
0 KB |
- |