# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
788100 |
2023-07-19T18:31:27 Z |
rainboy |
Towers (NOI22_towers) |
C |
|
565 ms |
50100 KB |
#include <stdio.h>
#include <string.h>
#define N 1000000
#define INF 0x3f3f3f3f
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
unsigned int X = 12345;
int rand_() {
return (X *= 3) >> 1;
}
int *uu, *vv;
void sort(int *ii, int l, int r) {
while (l < r) {
int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;
while (j < k) {
int c = uu[ii[j]] != uu[i_] ? uu[ii[j]] - uu[i_] : vv[ii[j]] - vv[i_];
if (c == 0)
j++;
else if (c < 0) {
tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
i++, j++;
} else {
k--;
tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
}
}
sort(ii, l, i);
l = k;
}
}
int xx[N], yy[N], iix[N], iiy[N], hhx[N], hhy[N], hxl[N], hxr[N], hyl[N], hyr[N];
void add(int i) {
int x, y, hx, hy, tmp;
y = yy[i], hy = hhy[i];
if (hyl[y] >= hyr[y])
hyl[y] = min(hyl[y], hy), hyr[y] = max(hyr[y], hy);
else {
if (hyl[y] > hy)
tmp = hy, hy = hyl[y], hyl[y] = tmp;
else if (hyr[y] < hy)
tmp = hy, hy = hyr[y], hyr[y] = tmp;
i = iiy[hy];
x = xx[i], hx = hhx[i];
if (hx == hxl[x])
hx = ++hxl[x];
else if (hx == hxr[x])
hx = --hxr[x];
if (hxl[x] < hxr[x])
add(iix[hx]);
}
}
int main() {
static char cc[N + 1];
int n, nx, ny, h, i, x;
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d%d", &xx[i], &yy[i]);
for (i = 0; i < n; i++)
iix[i] = i;
uu = xx, vv = yy, sort(iix, 0, n);
nx = 0;
for (h = 0; h < n; h++) {
i = iix[h];
xx[i] = h + 1 == n || xx[iix[h + 1]] != xx[i] ? nx++ : nx;
hhx[i] = h;
}
for (i = 0; i < n; i++)
iiy[i] = i;
uu = yy, vv = xx, sort(iiy, 0, n);
ny = 0;
for (h = 0; h < n; h++) {
i = iiy[h];
yy[i] = h + 1 == n || yy[iiy[h + 1]] != yy[i] ? ny++ : ny;
hhy[i] = h;
}
memset(hxl, 0x3f, nx * sizeof *hxl), memset(hxr, -1, nx * sizeof *hxr);
memset(hyl, 0x3f, ny * sizeof *hyl), memset(hyr, -1, ny * sizeof *hyr);
for (h = 0; h < n; h++) {
i = iix[h], x = xx[i];
hxl[x] = min(hxl[x], hhx[i]), hxr[x] = max(hxr[x], hhx[i]);
}
for (x = 0; x < nx; x++) {
add(iix[hxl[x]]);
if (hxl[x] < hxr[x])
add(iix[hxr[x]]);
}
for (x = 0; x < nx; x++)
if (hxl[x] <= hxr[x])
cc[iix[hxl[x]]] = cc[iix[hxr[x]]] = 1;
for (i = 0; i < n; i++)
cc[i] += '0';
printf("%s\n", cc);
return 0;
}
Compilation message
Main.c: In function 'main':
Main.c:68:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
68 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
Main.c:70:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
70 | scanf("%d%d", &xx[i], &yy[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 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 |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 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 |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
0 ms |
340 KB |
Output is correct |
25 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
2636 KB |
Output is correct |
2 |
Correct |
35 ms |
3152 KB |
Output is correct |
3 |
Correct |
123 ms |
9016 KB |
Output is correct |
4 |
Correct |
238 ms |
17360 KB |
Output is correct |
5 |
Correct |
41 ms |
3356 KB |
Output is correct |
6 |
Correct |
9 ms |
980 KB |
Output is correct |
7 |
Correct |
240 ms |
16332 KB |
Output is correct |
8 |
Correct |
142 ms |
10972 KB |
Output is correct |
9 |
Correct |
355 ms |
24096 KB |
Output is correct |
10 |
Correct |
269 ms |
20284 KB |
Output is correct |
11 |
Correct |
372 ms |
25676 KB |
Output is correct |
12 |
Correct |
388 ms |
33412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
472 ms |
31884 KB |
Output is correct |
2 |
Correct |
461 ms |
44364 KB |
Output is correct |
3 |
Correct |
464 ms |
44380 KB |
Output is correct |
4 |
Correct |
464 ms |
44392 KB |
Output is correct |
5 |
Correct |
483 ms |
44364 KB |
Output is correct |
6 |
Correct |
446 ms |
50100 KB |
Output is correct |
7 |
Correct |
456 ms |
49980 KB |
Output is correct |
8 |
Correct |
438 ms |
49992 KB |
Output is correct |
9 |
Correct |
443 ms |
49952 KB |
Output is correct |
10 |
Correct |
479 ms |
50040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 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 |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 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 |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
0 ms |
340 KB |
Output is correct |
25 |
Correct |
0 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
2 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
33 |
Correct |
2 ms |
468 KB |
Output is correct |
34 |
Correct |
2 ms |
468 KB |
Output is correct |
35 |
Correct |
2 ms |
468 KB |
Output is correct |
36 |
Correct |
2 ms |
468 KB |
Output is correct |
37 |
Correct |
2 ms |
484 KB |
Output is correct |
38 |
Correct |
2 ms |
468 KB |
Output is correct |
39 |
Correct |
2 ms |
468 KB |
Output is correct |
40 |
Correct |
2 ms |
468 KB |
Output is correct |
41 |
Correct |
2 ms |
468 KB |
Output is correct |
42 |
Correct |
2 ms |
428 KB |
Output is correct |
43 |
Correct |
2 ms |
468 KB |
Output is correct |
44 |
Correct |
2 ms |
468 KB |
Output is correct |
45 |
Correct |
2 ms |
468 KB |
Output is correct |
46 |
Correct |
2 ms |
468 KB |
Output is correct |
47 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 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 |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 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 |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
0 ms |
340 KB |
Output is correct |
25 |
Correct |
0 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
2 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
33 |
Correct |
2 ms |
468 KB |
Output is correct |
34 |
Correct |
2 ms |
468 KB |
Output is correct |
35 |
Correct |
2 ms |
468 KB |
Output is correct |
36 |
Correct |
2 ms |
468 KB |
Output is correct |
37 |
Correct |
2 ms |
484 KB |
Output is correct |
38 |
Correct |
2 ms |
468 KB |
Output is correct |
39 |
Correct |
2 ms |
468 KB |
Output is correct |
40 |
Correct |
2 ms |
468 KB |
Output is correct |
41 |
Correct |
2 ms |
468 KB |
Output is correct |
42 |
Correct |
2 ms |
428 KB |
Output is correct |
43 |
Correct |
2 ms |
468 KB |
Output is correct |
44 |
Correct |
2 ms |
468 KB |
Output is correct |
45 |
Correct |
2 ms |
468 KB |
Output is correct |
46 |
Correct |
2 ms |
468 KB |
Output is correct |
47 |
Correct |
2 ms |
468 KB |
Output is correct |
48 |
Correct |
34 ms |
4300 KB |
Output is correct |
49 |
Correct |
34 ms |
4340 KB |
Output is correct |
50 |
Correct |
47 ms |
3820 KB |
Output is correct |
51 |
Correct |
43 ms |
3772 KB |
Output is correct |
52 |
Correct |
43 ms |
3044 KB |
Output is correct |
53 |
Correct |
46 ms |
3140 KB |
Output is correct |
54 |
Correct |
41 ms |
3016 KB |
Output is correct |
55 |
Correct |
44 ms |
2892 KB |
Output is correct |
56 |
Correct |
41 ms |
2884 KB |
Output is correct |
57 |
Correct |
40 ms |
2888 KB |
Output is correct |
58 |
Correct |
41 ms |
2788 KB |
Output is correct |
59 |
Correct |
41 ms |
2884 KB |
Output is correct |
60 |
Correct |
41 ms |
2784 KB |
Output is correct |
61 |
Correct |
42 ms |
2888 KB |
Output is correct |
62 |
Correct |
48 ms |
2788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 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 |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 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 |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
0 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
340 KB |
Output is correct |
24 |
Correct |
0 ms |
340 KB |
Output is correct |
25 |
Correct |
0 ms |
340 KB |
Output is correct |
26 |
Correct |
29 ms |
2636 KB |
Output is correct |
27 |
Correct |
35 ms |
3152 KB |
Output is correct |
28 |
Correct |
123 ms |
9016 KB |
Output is correct |
29 |
Correct |
238 ms |
17360 KB |
Output is correct |
30 |
Correct |
41 ms |
3356 KB |
Output is correct |
31 |
Correct |
9 ms |
980 KB |
Output is correct |
32 |
Correct |
240 ms |
16332 KB |
Output is correct |
33 |
Correct |
142 ms |
10972 KB |
Output is correct |
34 |
Correct |
355 ms |
24096 KB |
Output is correct |
35 |
Correct |
269 ms |
20284 KB |
Output is correct |
36 |
Correct |
372 ms |
25676 KB |
Output is correct |
37 |
Correct |
388 ms |
33412 KB |
Output is correct |
38 |
Correct |
472 ms |
31884 KB |
Output is correct |
39 |
Correct |
461 ms |
44364 KB |
Output is correct |
40 |
Correct |
464 ms |
44380 KB |
Output is correct |
41 |
Correct |
464 ms |
44392 KB |
Output is correct |
42 |
Correct |
483 ms |
44364 KB |
Output is correct |
43 |
Correct |
446 ms |
50100 KB |
Output is correct |
44 |
Correct |
456 ms |
49980 KB |
Output is correct |
45 |
Correct |
438 ms |
49992 KB |
Output is correct |
46 |
Correct |
443 ms |
49952 KB |
Output is correct |
47 |
Correct |
479 ms |
50040 KB |
Output is correct |
48 |
Correct |
2 ms |
468 KB |
Output is correct |
49 |
Correct |
2 ms |
468 KB |
Output is correct |
50 |
Correct |
2 ms |
468 KB |
Output is correct |
51 |
Correct |
2 ms |
468 KB |
Output is correct |
52 |
Correct |
2 ms |
468 KB |
Output is correct |
53 |
Correct |
2 ms |
468 KB |
Output is correct |
54 |
Correct |
2 ms |
468 KB |
Output is correct |
55 |
Correct |
2 ms |
468 KB |
Output is correct |
56 |
Correct |
2 ms |
468 KB |
Output is correct |
57 |
Correct |
2 ms |
468 KB |
Output is correct |
58 |
Correct |
2 ms |
468 KB |
Output is correct |
59 |
Correct |
2 ms |
484 KB |
Output is correct |
60 |
Correct |
2 ms |
468 KB |
Output is correct |
61 |
Correct |
2 ms |
468 KB |
Output is correct |
62 |
Correct |
2 ms |
468 KB |
Output is correct |
63 |
Correct |
2 ms |
468 KB |
Output is correct |
64 |
Correct |
2 ms |
428 KB |
Output is correct |
65 |
Correct |
2 ms |
468 KB |
Output is correct |
66 |
Correct |
2 ms |
468 KB |
Output is correct |
67 |
Correct |
2 ms |
468 KB |
Output is correct |
68 |
Correct |
2 ms |
468 KB |
Output is correct |
69 |
Correct |
2 ms |
468 KB |
Output is correct |
70 |
Correct |
34 ms |
4300 KB |
Output is correct |
71 |
Correct |
34 ms |
4340 KB |
Output is correct |
72 |
Correct |
47 ms |
3820 KB |
Output is correct |
73 |
Correct |
43 ms |
3772 KB |
Output is correct |
74 |
Correct |
43 ms |
3044 KB |
Output is correct |
75 |
Correct |
46 ms |
3140 KB |
Output is correct |
76 |
Correct |
41 ms |
3016 KB |
Output is correct |
77 |
Correct |
44 ms |
2892 KB |
Output is correct |
78 |
Correct |
41 ms |
2884 KB |
Output is correct |
79 |
Correct |
40 ms |
2888 KB |
Output is correct |
80 |
Correct |
41 ms |
2788 KB |
Output is correct |
81 |
Correct |
41 ms |
2884 KB |
Output is correct |
82 |
Correct |
41 ms |
2784 KB |
Output is correct |
83 |
Correct |
42 ms |
2888 KB |
Output is correct |
84 |
Correct |
48 ms |
2788 KB |
Output is correct |
85 |
Correct |
0 ms |
340 KB |
Output is correct |
86 |
Correct |
0 ms |
340 KB |
Output is correct |
87 |
Correct |
0 ms |
300 KB |
Output is correct |
88 |
Correct |
435 ms |
49076 KB |
Output is correct |
89 |
Correct |
455 ms |
49080 KB |
Output is correct |
90 |
Correct |
429 ms |
49016 KB |
Output is correct |
91 |
Correct |
519 ms |
40720 KB |
Output is correct |
92 |
Correct |
525 ms |
40780 KB |
Output is correct |
93 |
Correct |
522 ms |
40816 KB |
Output is correct |
94 |
Correct |
533 ms |
39988 KB |
Output is correct |
95 |
Correct |
506 ms |
39972 KB |
Output is correct |
96 |
Correct |
565 ms |
39988 KB |
Output is correct |
97 |
Correct |
562 ms |
39652 KB |
Output is correct |
98 |
Correct |
528 ms |
39608 KB |
Output is correct |
99 |
Correct |
519 ms |
39608 KB |
Output is correct |
100 |
Correct |
499 ms |
39348 KB |
Output is correct |
101 |
Correct |
553 ms |
39300 KB |
Output is correct |
102 |
Correct |
526 ms |
39256 KB |
Output is correct |
103 |
Correct |
517 ms |
39244 KB |
Output is correct |
104 |
Correct |
525 ms |
39216 KB |
Output is correct |
105 |
Correct |
521 ms |
39180 KB |
Output is correct |
106 |
Correct |
519 ms |
39216 KB |
Output is correct |
107 |
Correct |
521 ms |
39244 KB |
Output is correct |