Submission #73971861
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <stdlib.h>
int cmp(const void* x, const void* y) {
int a = *(const int*)x, b = *(const int*)y;
return (a > b) - (a < b);
}
int zac;
int zal[212345 * 2];
int zaq(int query) {
int l = 0, r = zac - 1;
while (l <= r) {
int m = l + (r - l) / 2;
if (zal[m] == query) return m;
else if (zal[m] < query) l = m + 1;
else r = m - 1;
}
printf("ERROR: %d not found\n", query);
exit(72);
}
#define KI_MAX (1 << 19) /* 524288 */
int ki[KI_MAX * 2 - 1];
char ki_all[KI_MAX * 2 - 1];
/* 黒にする */
int ki_set_i(int idx, int ss, int se, int qs, int qe) {
if (qs <= ss && se <= qe) { /* セグメントがクエリに完全に含まれる */
ki_all[idx] = 1;
} else if (qe <= ss || se <= qs) { /* 完全に外れている */
/* 何もしない */
} else {
int sm = ss + (se - ss) / 2;
ki[idx] = ki_set_i(idx * 2 + 1, ss, sm, qs, qe) +
ki_set_i(idx * 2 + 2, sm, se, qs, qe);
}
return ki_all[idx] ? zal[se] - zal[ss] : ki[idx];
}
void ki_set(int qs, int qe) {
ki_set_i(0, 0, KI_MAX, qs, qe);
}
/* 黒く塗られているマスの個数を求める */
int ki_get_i(int idx, int ss, int se, int qs, int qe) {
if (qe <= ss || se <= qs) { /* 完全に外れている */
return 0;
} else if (ki_all[idx]) { /* 範囲内全マスが黒く塗られている */
int l = ss <= qs ? qs : ss;
int r = se <= qe ? se : qe;
return zal[r] - zal[l];
} else if (qs <= ss && se <= qe) { /* セグメントがクエリに完全に含まれる */
return ki[idx];
} else {
int sm = ss + (se - ss) / 2;
return ki_get_i(idx * 2 + 1, ss, sm, qs, qe) +
ki_get_i(idx * 2 + 2, sm, se, qs, qe);
}
}
int ki_get(int qs, int qe) {
return ki_get_i(0, 0, KI_MAX, qs, qe);
}
int N, Q;
int L[212345], R[212345];
int main(void) {
int i;
if (scanf("%d%d", &N, &Q) != 2) return 1;
for (i = 0; i < Q; i++) {
if (scanf("%d%d", &L[i], &R[i]) != 2) return 1;
zal[i * 2] = L[i];
zal[i * 2 + 1] = R[i] + 1;
}
zal[Q * 2] = N + 1;
qsort(zal, Q * 2 + 1, sizeof(*zal), cmp);
for (i = 1, zac = 1; i < Q * 2 + 1; i++) {
if (zal[zac - 1] != zal[i]) zal[zac++] = zal[i];
}
for (i = 0; i < Q; i++) {
ki_set(zaq(L[i]), zaq(R[i] + 1));
printf("%d\n", N - ki_get(0, zac - 1));
}
return 0;
}
Submission Info
Submission Time
2026-03-09 19:36:40
Task
E - Cover query
User
mikecat
Language
C23 (GCC 14.2.0)
Score
450
Code Size
2331 Byte
Status
AC
Exec Time
221 ms
Memory
7980 KiB
Compile Error
In function ‘ki_set_i’,
inlined from ‘ki_set’ at Main.c:45:2:
Main.c:41:33: warning: array subscript 524288 is above array bounds of ‘int[424690]’ [-Warray-bounds=]
41 | return ki_all[idx] ? zal[se] - zal[ss] : ki[idx];
| ~~~^~~~
Main.c: In function ‘ki_set’:
Main.c:10:5: note: while referencing ‘zal’
10 | int zal[212345 * 2];
| ^~~
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
450 / 450
Status
Set Name
Test Cases
Sample
example_00.txt, example_01.txt
All
example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt
Case Name
Status
Exec Time
Memory
example_00.txt
AC
0 ms
1716 KiB
example_01.txt
AC
0 ms
1816 KiB
hand_00.txt
AC
92 ms
7468 KiB
hand_01.txt
AC
90 ms
6512 KiB
hand_02.txt
AC
99 ms
7664 KiB
hand_03.txt
AC
118 ms
7964 KiB
hand_04.txt
AC
99 ms
7616 KiB
hand_05.txt
AC
105 ms
7532 KiB
hand_06.txt
AC
99 ms
7456 KiB
hand_07.txt
AC
71 ms
5880 KiB
hand_08.txt
AC
68 ms
5860 KiB
hand_09.txt
AC
76 ms
5816 KiB
hand_10.txt
AC
67 ms
5768 KiB
hand_11.txt
AC
66 ms
5468 KiB
random_00.txt
AC
219 ms
7232 KiB
random_01.txt
AC
219 ms
7220 KiB
random_02.txt
AC
219 ms
7224 KiB
random_03.txt
AC
219 ms
7124 KiB
random_04.txt
AC
221 ms
7244 KiB
random_05.txt
AC
167 ms
7748 KiB
random_06.txt
AC
166 ms
7896 KiB
random_07.txt
AC
167 ms
7856 KiB
random_08.txt
AC
166 ms
7788 KiB
random_09.txt
AC
166 ms
7828 KiB
random_10.txt
AC
145 ms
6208 KiB
random_11.txt
AC
145 ms
6256 KiB
random_12.txt
AC
144 ms
6200 KiB
random_13.txt
AC
145 ms
6296 KiB
random_14.txt
AC
144 ms
6256 KiB
random_15.txt
AC
128 ms
6244 KiB
random_16.txt
AC
127 ms
6296 KiB
random_17.txt
AC
126 ms
6204 KiB
random_18.txt
AC
127 ms
6296 KiB
random_19.txt
AC
127 ms
6256 KiB
random_20.txt
AC
168 ms
7800 KiB
random_21.txt
AC
172 ms
7852 KiB
random_22.txt
AC
171 ms
7772 KiB
random_23.txt
AC
167 ms
7788 KiB
random_24.txt
AC
169 ms
7980 KiB
random_25.txt
AC
189 ms
7172 KiB
random_26.txt
AC
188 ms
7152 KiB
random_27.txt
AC
186 ms
7220 KiB