#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
using namespace std;
struct LazySegtree {
vector <int> t, lt;
int n;
void init(int size) {
n = size;
t = lt = vector<int>(n * 4, inf);
}
void push(int v) {
// sol için
t[v * 2] = min(t[v * 2], lt[v]);
lt[v * 2] = min(lt[v * 2], lt[v]);
// sağ için
t[v * 2 + 1] = min(t[v * 2 + 1], lt[v]);
lt[v * 2 + 1] = min(lt[v * 2 + 1], lt[v]);
lt[v] = inf;
}
void update(int v, int l, int r, int ql, int qr, int val) {
if(l >= ql and r <= qr) {
t[v] = min(t[v], val);
lt[v] = min(lt[v], val);
return;
}
push(v);
int m = (l + r) / 2;
if(ql <= m) {
update(v * 2, l, m, ql, qr, val);
}
if(qr > m) {
update(v * 2 + 1, m + 1, r, ql, qr, val);
}
t[v] = max(t[v * 2], t[v * 2 + 1]);
}
int query(int v, int l, int r, int ql, int qr) {
if(l >= ql and r <= qr) {
return t[v];
}
push(v);
int ans = 0;
int m = (l + r) / 2;
if(ql <= m) {
ans = max(ans, query(v * 2, l, m, ql, qr));
}
if(qr > m) {
ans = max(ans, query(v * 2 + 1, m + 1, r, ql, qr));
}
return ans;
}
};
int32_t main(){
fast
int n, m, q;
cin >> n >> m >> q;
vector <pair<int, int> > cur;
vector <array<int, 3> > qq;
for(int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
cur.push_back({a, b});
}
for(int i = 0; i < q; i++) {
int a, b;
cin >> a >> b;
qq.push_back({a, b, i});
}
sort(cur.begin(), cur.end());
sort(qq.begin(), qq.end());
reverse(cur.begin(), cur.end());
reverse(qq.begin(), qq.end());
bitset <500000> ans;
int p = 0;
LazySegtree st;
st.init(n + 1);
for(int i = 0; i < q; i++) {
int ql = qq[i][0], qr = qq[i][1], qi = qq[i][2];
while(ql <= cur[p].first and p < m) {
// update segt for ul, ur
int ul = cur[p].first, ur = cur[p].second;
st.update(1, 1, n, ul, ur, ur);
p++;
}
// direk range maxın <= qr olup olması
ans[qi] = qr == st.query(1, 1, n, ql, qr);
}
for(int i = 0; i < q; i++) {
cout << (ans[i] ? "YES" : "NO") << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
500 KB |
Output is correct |
5 |
Correct |
1 ms |
424 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
500 KB |
Output is correct |
5 |
Correct |
1 ms |
424 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
600 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
2 ms |
604 KB |
Output is correct |
17 |
Correct |
2 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
2 ms |
604 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
500 KB |
Output is correct |
5 |
Correct |
1 ms |
424 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
600 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
2 ms |
604 KB |
Output is correct |
17 |
Correct |
2 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
2 ms |
604 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
202 ms |
13764 KB |
Output is correct |
23 |
Correct |
205 ms |
14336 KB |
Output is correct |
24 |
Correct |
249 ms |
17472 KB |
Output is correct |
25 |
Correct |
413 ms |
28068 KB |
Output is correct |
26 |
Correct |
205 ms |
14844 KB |
Output is correct |
27 |
Correct |
447 ms |
28240 KB |
Output is correct |
28 |
Correct |
391 ms |
28088 KB |
Output is correct |
29 |
Correct |
198 ms |
14092 KB |
Output is correct |
30 |
Correct |
171 ms |
14584 KB |
Output is correct |
31 |
Correct |
188 ms |
15652 KB |
Output is correct |
32 |
Correct |
353 ms |
29020 KB |
Output is correct |
33 |
Correct |
164 ms |
14392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
183 ms |
14324 KB |
Output is correct |
9 |
Correct |
187 ms |
15544 KB |
Output is correct |
10 |
Correct |
358 ms |
28004 KB |
Output is correct |
11 |
Correct |
166 ms |
14388 KB |
Output is correct |
12 |
Correct |
106 ms |
12488 KB |
Output is correct |
13 |
Correct |
100 ms |
12604 KB |
Output is correct |
14 |
Correct |
76 ms |
12876 KB |
Output is correct |
15 |
Correct |
86 ms |
12456 KB |
Output is correct |
16 |
Correct |
76 ms |
12476 KB |
Output is correct |
17 |
Correct |
75 ms |
12788 KB |
Output is correct |
18 |
Correct |
545 ms |
59088 KB |
Output is correct |
19 |
Correct |
602 ms |
59320 KB |
Output is correct |
20 |
Correct |
405 ms |
59248 KB |
Output is correct |
21 |
Correct |
400 ms |
59052 KB |
Output is correct |
22 |
Correct |
404 ms |
58840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
500 KB |
Output is correct |
5 |
Correct |
1 ms |
424 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
600 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
2 ms |
604 KB |
Output is correct |
17 |
Correct |
2 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
2 ms |
604 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
92 ms |
8144 KB |
Output is correct |
23 |
Correct |
92 ms |
6768 KB |
Output is correct |
24 |
Correct |
118 ms |
12400 KB |
Output is correct |
25 |
Correct |
116 ms |
12476 KB |
Output is correct |
26 |
Correct |
93 ms |
12664 KB |
Output is correct |
27 |
Correct |
111 ms |
12740 KB |
Output is correct |
28 |
Correct |
74 ms |
10984 KB |
Output is correct |
29 |
Correct |
87 ms |
12340 KB |
Output is correct |
30 |
Correct |
120 ms |
12760 KB |
Output is correct |
31 |
Correct |
129 ms |
13236 KB |
Output is correct |
32 |
Correct |
105 ms |
12480 KB |
Output is correct |
33 |
Correct |
106 ms |
12488 KB |
Output is correct |
34 |
Correct |
114 ms |
12376 KB |
Output is correct |
35 |
Correct |
133 ms |
12484 KB |
Output is correct |
36 |
Correct |
105 ms |
12476 KB |
Output is correct |
37 |
Correct |
109 ms |
12708 KB |
Output is correct |
38 |
Correct |
100 ms |
12476 KB |
Output is correct |
39 |
Correct |
88 ms |
12324 KB |
Output is correct |
40 |
Correct |
85 ms |
12756 KB |
Output is correct |
41 |
Correct |
76 ms |
12364 KB |
Output is correct |
42 |
Correct |
90 ms |
12980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
500 KB |
Output is correct |
5 |
Correct |
1 ms |
424 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
600 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
2 ms |
604 KB |
Output is correct |
17 |
Correct |
2 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
2 ms |
604 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
202 ms |
13764 KB |
Output is correct |
23 |
Correct |
205 ms |
14336 KB |
Output is correct |
24 |
Correct |
249 ms |
17472 KB |
Output is correct |
25 |
Correct |
413 ms |
28068 KB |
Output is correct |
26 |
Correct |
205 ms |
14844 KB |
Output is correct |
27 |
Correct |
447 ms |
28240 KB |
Output is correct |
28 |
Correct |
391 ms |
28088 KB |
Output is correct |
29 |
Correct |
198 ms |
14092 KB |
Output is correct |
30 |
Correct |
171 ms |
14584 KB |
Output is correct |
31 |
Correct |
188 ms |
15652 KB |
Output is correct |
32 |
Correct |
353 ms |
29020 KB |
Output is correct |
33 |
Correct |
164 ms |
14392 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
2 ms |
604 KB |
Output is correct |
39 |
Correct |
1 ms |
604 KB |
Output is correct |
40 |
Correct |
2 ms |
604 KB |
Output is correct |
41 |
Correct |
183 ms |
14324 KB |
Output is correct |
42 |
Correct |
187 ms |
15544 KB |
Output is correct |
43 |
Correct |
358 ms |
28004 KB |
Output is correct |
44 |
Correct |
166 ms |
14388 KB |
Output is correct |
45 |
Correct |
106 ms |
12488 KB |
Output is correct |
46 |
Correct |
100 ms |
12604 KB |
Output is correct |
47 |
Correct |
76 ms |
12876 KB |
Output is correct |
48 |
Correct |
86 ms |
12456 KB |
Output is correct |
49 |
Correct |
76 ms |
12476 KB |
Output is correct |
50 |
Correct |
75 ms |
12788 KB |
Output is correct |
51 |
Correct |
545 ms |
59088 KB |
Output is correct |
52 |
Correct |
602 ms |
59320 KB |
Output is correct |
53 |
Correct |
405 ms |
59248 KB |
Output is correct |
54 |
Correct |
400 ms |
59052 KB |
Output is correct |
55 |
Correct |
404 ms |
58840 KB |
Output is correct |
56 |
Correct |
92 ms |
8144 KB |
Output is correct |
57 |
Correct |
92 ms |
6768 KB |
Output is correct |
58 |
Correct |
118 ms |
12400 KB |
Output is correct |
59 |
Correct |
116 ms |
12476 KB |
Output is correct |
60 |
Correct |
93 ms |
12664 KB |
Output is correct |
61 |
Correct |
111 ms |
12740 KB |
Output is correct |
62 |
Correct |
74 ms |
10984 KB |
Output is correct |
63 |
Correct |
87 ms |
12340 KB |
Output is correct |
64 |
Correct |
120 ms |
12760 KB |
Output is correct |
65 |
Correct |
129 ms |
13236 KB |
Output is correct |
66 |
Correct |
105 ms |
12480 KB |
Output is correct |
67 |
Correct |
106 ms |
12488 KB |
Output is correct |
68 |
Correct |
114 ms |
12376 KB |
Output is correct |
69 |
Correct |
133 ms |
12484 KB |
Output is correct |
70 |
Correct |
105 ms |
12476 KB |
Output is correct |
71 |
Correct |
109 ms |
12708 KB |
Output is correct |
72 |
Correct |
100 ms |
12476 KB |
Output is correct |
73 |
Correct |
88 ms |
12324 KB |
Output is correct |
74 |
Correct |
85 ms |
12756 KB |
Output is correct |
75 |
Correct |
76 ms |
12364 KB |
Output is correct |
76 |
Correct |
90 ms |
12980 KB |
Output is correct |
77 |
Correct |
705 ms |
59088 KB |
Output is correct |
78 |
Correct |
724 ms |
59384 KB |
Output is correct |
79 |
Correct |
551 ms |
72844 KB |
Output is correct |
80 |
Correct |
555 ms |
73132 KB |
Output is correct |
81 |
Correct |
561 ms |
72628 KB |
Output is correct |
82 |
Correct |
617 ms |
72016 KB |
Output is correct |
83 |
Correct |
798 ms |
72436 KB |
Output is correct |
84 |
Correct |
796 ms |
72420 KB |
Output is correct |
85 |
Correct |
643 ms |
72372 KB |
Output is correct |
86 |
Correct |
659 ms |
72248 KB |
Output is correct |
87 |
Correct |
695 ms |
71208 KB |
Output is correct |
88 |
Correct |
556 ms |
72184 KB |
Output is correct |