# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
828153 |
2023-08-17T06:06:02 Z |
박상훈(#10381) |
Curtains (NOI23_curtains) |
C++17 |
|
862 ms |
43292 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int INF = 1e9 + 100;
struct Seg{
int tree[1101000], lazy[1101000];
void propagate(int i, int l, int r){
tree[i] = max(tree[i], lazy[i]);
if (l!=r){
lazy[i<<1] = max(lazy[i<<1], lazy[i]);
lazy[i<<1|1] = max(lazy[i<<1|1], lazy[i]);
}
lazy[i] = 0;
}
void update(int i, int l, int r, int s, int e, int x){
propagate(i, l, r);
if (r<s || e<l) return;
if (s<=l && r<=e){
lazy[i] = max(lazy[i], x);
propagate(i, l, r);
return;
}
int m = (l+r)>>1;
update(i<<1, l, m, s, e, x); update(i<<1|1, m+1, r, s, e, x);
tree[i] = min(tree[i<<1], tree[i<<1|1]);
}
int query(int i, int l, int r, int s, int e){
propagate(i, l, r);
if (r<s || e<l) return INF;
if (s<=l && r<=e) return tree[i];
int m = (l+r)>>1;
return min(query(i<<1, l, m, s, e), query(i<<1|1, m+1, r, s, e));
}
}tree;
int L[500500], R[500500], S[500500], E[500500], ans[500500];
int main(){
int n, m, q;
scanf("%d %d %d", &n, &m, &q);
vector<array<int, 3>> Ev;
for (int i=1;i<=m;i++){
scanf("%d %d", L+i, R+i);
Ev.push_back({R[i], 0, i});
}
for (int i=1;i<=q;i++){
scanf("%d %d", S+i, E+i);
Ev.push_back({E[i], 1, i});
}
sort(Ev.begin(), Ev.end());
for (auto &[x, typ, i]:Ev){
if (typ==0){
tree.update(1, 1, n, L[i], R[i], L[i]);
// printf(" update %d %d\n", L[i], R[i]);
// for (int i=1;i<=n;i++) printf(" %d", tree.query(1, 1, n, i, i));
// printf("\n");
}
else{
// printf("%d %d -> %d\n", S[i], E[i], tree.query(1, 1, n, S[i], E[i]));
ans[i] = (tree.query(1, 1, n, S[i], E[i]) == S[i]);
}
}
for (int i=1;i<=q;i++){
if (ans[i]) printf("YES\n");
else printf("NO\n");
}
}
Compilation message
curtains.cpp: In function 'int main()':
curtains.cpp:49:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
49 | scanf("%d %d %d", &n, &m, &q);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:54:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
54 | scanf("%d %d", L+i, R+i);
| ~~~~~^~~~~~~~~~~~~~~~~~~
curtains.cpp:59:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
59 | scanf("%d %d", S+i, E+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 |
1 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 |
312 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 |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 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 |
1 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 |
312 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 |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
2 ms |
452 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
2 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
528 KB |
Output is correct |
21 |
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 |
1 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 |
312 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 |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
2 ms |
452 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
2 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
528 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
22 |
Correct |
246 ms |
17488 KB |
Output is correct |
23 |
Correct |
258 ms |
17888 KB |
Output is correct |
24 |
Correct |
307 ms |
20512 KB |
Output is correct |
25 |
Correct |
535 ms |
31628 KB |
Output is correct |
26 |
Correct |
252 ms |
17812 KB |
Output is correct |
27 |
Correct |
538 ms |
31732 KB |
Output is correct |
28 |
Correct |
549 ms |
32116 KB |
Output is correct |
29 |
Correct |
244 ms |
17492 KB |
Output is correct |
30 |
Correct |
194 ms |
16888 KB |
Output is correct |
31 |
Correct |
221 ms |
19884 KB |
Output is correct |
32 |
Correct |
520 ms |
30660 KB |
Output is correct |
33 |
Correct |
189 ms |
17256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 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 |
2 ms |
440 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
2 ms |
448 KB |
Output is correct |
8 |
Correct |
191 ms |
16908 KB |
Output is correct |
9 |
Correct |
227 ms |
19888 KB |
Output is correct |
10 |
Correct |
485 ms |
30628 KB |
Output is correct |
11 |
Correct |
204 ms |
16944 KB |
Output is correct |
12 |
Correct |
111 ms |
8884 KB |
Output is correct |
13 |
Correct |
111 ms |
8816 KB |
Output is correct |
14 |
Correct |
91 ms |
8704 KB |
Output is correct |
15 |
Correct |
98 ms |
8744 KB |
Output is correct |
16 |
Correct |
96 ms |
8764 KB |
Output is correct |
17 |
Correct |
93 ms |
8700 KB |
Output is correct |
18 |
Correct |
687 ms |
41108 KB |
Output is correct |
19 |
Correct |
712 ms |
39688 KB |
Output is correct |
20 |
Correct |
532 ms |
40904 KB |
Output is correct |
21 |
Correct |
529 ms |
39704 KB |
Output is correct |
22 |
Correct |
547 ms |
39644 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 |
1 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 |
312 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 |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
2 ms |
452 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
2 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
528 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
22 |
Correct |
123 ms |
7076 KB |
Output is correct |
23 |
Correct |
112 ms |
7192 KB |
Output is correct |
24 |
Correct |
129 ms |
8872 KB |
Output is correct |
25 |
Correct |
129 ms |
9220 KB |
Output is correct |
26 |
Correct |
110 ms |
9040 KB |
Output is correct |
27 |
Correct |
111 ms |
8952 KB |
Output is correct |
28 |
Correct |
84 ms |
7736 KB |
Output is correct |
29 |
Correct |
103 ms |
8776 KB |
Output is correct |
30 |
Correct |
156 ms |
9276 KB |
Output is correct |
31 |
Correct |
129 ms |
9176 KB |
Output is correct |
32 |
Correct |
124 ms |
9104 KB |
Output is correct |
33 |
Correct |
108 ms |
9320 KB |
Output is correct |
34 |
Correct |
139 ms |
9004 KB |
Output is correct |
35 |
Correct |
129 ms |
8684 KB |
Output is correct |
36 |
Correct |
117 ms |
9012 KB |
Output is correct |
37 |
Correct |
110 ms |
8876 KB |
Output is correct |
38 |
Correct |
117 ms |
8964 KB |
Output is correct |
39 |
Correct |
91 ms |
8840 KB |
Output is correct |
40 |
Correct |
91 ms |
8372 KB |
Output is correct |
41 |
Correct |
104 ms |
8692 KB |
Output is correct |
42 |
Correct |
92 ms |
8744 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 |
1 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 |
312 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 |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
2 ms |
452 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
2 ms |
468 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
2 ms |
468 KB |
Output is correct |
20 |
Correct |
2 ms |
528 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
22 |
Correct |
246 ms |
17488 KB |
Output is correct |
23 |
Correct |
258 ms |
17888 KB |
Output is correct |
24 |
Correct |
307 ms |
20512 KB |
Output is correct |
25 |
Correct |
535 ms |
31628 KB |
Output is correct |
26 |
Correct |
252 ms |
17812 KB |
Output is correct |
27 |
Correct |
538 ms |
31732 KB |
Output is correct |
28 |
Correct |
549 ms |
32116 KB |
Output is correct |
29 |
Correct |
244 ms |
17492 KB |
Output is correct |
30 |
Correct |
194 ms |
16888 KB |
Output is correct |
31 |
Correct |
221 ms |
19884 KB |
Output is correct |
32 |
Correct |
520 ms |
30660 KB |
Output is correct |
33 |
Correct |
189 ms |
17256 KB |
Output is correct |
34 |
Correct |
0 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
0 ms |
340 KB |
Output is correct |
38 |
Correct |
2 ms |
440 KB |
Output is correct |
39 |
Correct |
2 ms |
468 KB |
Output is correct |
40 |
Correct |
2 ms |
448 KB |
Output is correct |
41 |
Correct |
191 ms |
16908 KB |
Output is correct |
42 |
Correct |
227 ms |
19888 KB |
Output is correct |
43 |
Correct |
485 ms |
30628 KB |
Output is correct |
44 |
Correct |
204 ms |
16944 KB |
Output is correct |
45 |
Correct |
111 ms |
8884 KB |
Output is correct |
46 |
Correct |
111 ms |
8816 KB |
Output is correct |
47 |
Correct |
91 ms |
8704 KB |
Output is correct |
48 |
Correct |
98 ms |
8744 KB |
Output is correct |
49 |
Correct |
96 ms |
8764 KB |
Output is correct |
50 |
Correct |
93 ms |
8700 KB |
Output is correct |
51 |
Correct |
687 ms |
41108 KB |
Output is correct |
52 |
Correct |
712 ms |
39688 KB |
Output is correct |
53 |
Correct |
532 ms |
40904 KB |
Output is correct |
54 |
Correct |
529 ms |
39704 KB |
Output is correct |
55 |
Correct |
547 ms |
39644 KB |
Output is correct |
56 |
Correct |
123 ms |
7076 KB |
Output is correct |
57 |
Correct |
112 ms |
7192 KB |
Output is correct |
58 |
Correct |
129 ms |
8872 KB |
Output is correct |
59 |
Correct |
129 ms |
9220 KB |
Output is correct |
60 |
Correct |
110 ms |
9040 KB |
Output is correct |
61 |
Correct |
111 ms |
8952 KB |
Output is correct |
62 |
Correct |
84 ms |
7736 KB |
Output is correct |
63 |
Correct |
103 ms |
8776 KB |
Output is correct |
64 |
Correct |
156 ms |
9276 KB |
Output is correct |
65 |
Correct |
129 ms |
9176 KB |
Output is correct |
66 |
Correct |
124 ms |
9104 KB |
Output is correct |
67 |
Correct |
108 ms |
9320 KB |
Output is correct |
68 |
Correct |
139 ms |
9004 KB |
Output is correct |
69 |
Correct |
129 ms |
8684 KB |
Output is correct |
70 |
Correct |
117 ms |
9012 KB |
Output is correct |
71 |
Correct |
110 ms |
8876 KB |
Output is correct |
72 |
Correct |
117 ms |
8964 KB |
Output is correct |
73 |
Correct |
91 ms |
8840 KB |
Output is correct |
74 |
Correct |
91 ms |
8372 KB |
Output is correct |
75 |
Correct |
104 ms |
8692 KB |
Output is correct |
76 |
Correct |
92 ms |
8744 KB |
Output is correct |
77 |
Correct |
840 ms |
42588 KB |
Output is correct |
78 |
Correct |
834 ms |
42576 KB |
Output is correct |
79 |
Correct |
680 ms |
42852 KB |
Output is correct |
80 |
Correct |
654 ms |
41996 KB |
Output is correct |
81 |
Correct |
661 ms |
40744 KB |
Output is correct |
82 |
Correct |
655 ms |
43292 KB |
Output is correct |
83 |
Correct |
862 ms |
42204 KB |
Output is correct |
84 |
Correct |
859 ms |
42764 KB |
Output is correct |
85 |
Correct |
819 ms |
42376 KB |
Output is correct |
86 |
Correct |
770 ms |
41832 KB |
Output is correct |
87 |
Correct |
748 ms |
41280 KB |
Output is correct |
88 |
Correct |
665 ms |
41532 KB |
Output is correct |