#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9;
struct segtree{
int n, tl, tr;
vector<int> t, st, marked;
segtree(int _n){
n = _n;
st.resize(4*n, -1);
t.resize(4*n,-1);
marked.resize(4*n);
}
void push(int v, int l, int r){
if(!marked[v]) return;
if(l<r){
if(st[v*2] < t[v]){
st[v*2] = t[v];
t[v*2] = t[v];
marked[v*2] = 1;
}
if(st[v*2+1] < t[v]){
st[v*2+1] = t[v];
t[v*2+1] = t[v];
marked[v*2+1] = 1;
}
st[v] = merge(st[v*2], st[v*2+1]);
}
marked[v] = 0; t[v] = -1;
}
int merge(int x, int y){
return min(x, y);
}
void update(int v, int l, int r, int val){
push(v, l, r);
if(l>tr || r< tl) return;
if(r<=tr&&l>=tl){
if(st[v] < val){
t[v] = val;
st[v] = t[v];
marked[v] = 1;
}
}
else{
int mid = (l+r) / 2;
update(v*2, l, mid, val);
update(v*2+1, mid+1, r, val);
st[v] = merge(st[v*2], st[v*2+1]);
}
}
void update(int l, int r, int val){
tl = l; tr = r;
update(1, 0, n-1, val);
}
int get(int v, int l, int r){
push(v, l, r);
if(l>tr || r<tl) return 1e9;
else if(l>=tl&&r<=tr) return st[v];
else{
int mid = (l+r) / 2;
return merge(get(v*2, l, mid), get(v*2+1, mid+1, r));
}
}
int operator()(int l, int r){
tl = l, tr = r;
if(r<l) return 1e9;
else return get(1, 0, n-1);
}
};
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m, q; cin >> n >> m >> q;
vector<vector<int>> g(n);
for(int i=0; i<m; i++){
int x, y; cin >> x >> y;
x--; y--;
g[y].push_back(x);
}
vector<array<int, 2>> s;
segtree st(n);
vector<array<int, 3>> qu(q);
vector<int> ans(q);
for(int i=0; i<q; i++){
int x, y; cin >> x >> y;
x--; y--;
qu[i]={x, y, i};
}
sort(qu.begin(), qu.end(), [&](array<int, 3> a, array<int, 3> b){
return a[1] < b[1];
});
int l = 0;
for(auto [left, right, ind]: qu){
while(l<=right){
for(auto j: g[l]) st.update(j, l, j);
l++;
}
if(st(left, right) < left) ans[ind]=0;
else ans[ind]=1;
}
for(int i=0; i<q; i++){
if(ans[i]) cout<<"YES\n";
else cout<<"NO\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
452 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
452 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
604 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 |
600 KB |
Output is correct |
17 |
Correct |
2 ms |
604 KB |
Output is correct |
18 |
Correct |
2 ms |
604 KB |
Output is correct |
19 |
Correct |
2 ms |
600 KB |
Output is correct |
20 |
Correct |
2 ms |
736 KB |
Output is correct |
21 |
Correct |
3 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
452 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
604 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 |
600 KB |
Output is correct |
17 |
Correct |
2 ms |
604 KB |
Output is correct |
18 |
Correct |
2 ms |
604 KB |
Output is correct |
19 |
Correct |
2 ms |
600 KB |
Output is correct |
20 |
Correct |
2 ms |
736 KB |
Output is correct |
21 |
Correct |
3 ms |
604 KB |
Output is correct |
22 |
Correct |
171 ms |
20204 KB |
Output is correct |
23 |
Correct |
203 ms |
20936 KB |
Output is correct |
24 |
Correct |
202 ms |
22360 KB |
Output is correct |
25 |
Correct |
335 ms |
28952 KB |
Output is correct |
26 |
Correct |
182 ms |
20640 KB |
Output is correct |
27 |
Correct |
309 ms |
29012 KB |
Output is correct |
28 |
Correct |
316 ms |
28928 KB |
Output is correct |
29 |
Correct |
162 ms |
20308 KB |
Output is correct |
30 |
Correct |
119 ms |
20048 KB |
Output is correct |
31 |
Correct |
137 ms |
21076 KB |
Output is correct |
32 |
Correct |
262 ms |
28500 KB |
Output is correct |
33 |
Correct |
149 ms |
20096 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 |
724 KB |
Output is correct |
6 |
Correct |
2 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
680 KB |
Output is correct |
8 |
Correct |
126 ms |
20048 KB |
Output is correct |
9 |
Correct |
133 ms |
20868 KB |
Output is correct |
10 |
Correct |
264 ms |
28376 KB |
Output is correct |
11 |
Correct |
139 ms |
20308 KB |
Output is correct |
12 |
Correct |
98 ms |
18772 KB |
Output is correct |
13 |
Correct |
102 ms |
18772 KB |
Output is correct |
14 |
Correct |
76 ms |
18980 KB |
Output is correct |
15 |
Correct |
81 ms |
18700 KB |
Output is correct |
16 |
Correct |
84 ms |
18916 KB |
Output is correct |
17 |
Correct |
83 ms |
18512 KB |
Output is correct |
18 |
Correct |
643 ms |
91912 KB |
Output is correct |
19 |
Correct |
634 ms |
91916 KB |
Output is correct |
20 |
Correct |
453 ms |
92404 KB |
Output is correct |
21 |
Correct |
462 ms |
91728 KB |
Output is correct |
22 |
Correct |
451 ms |
91056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
452 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
604 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 |
600 KB |
Output is correct |
17 |
Correct |
2 ms |
604 KB |
Output is correct |
18 |
Correct |
2 ms |
604 KB |
Output is correct |
19 |
Correct |
2 ms |
600 KB |
Output is correct |
20 |
Correct |
2 ms |
736 KB |
Output is correct |
21 |
Correct |
3 ms |
604 KB |
Output is correct |
22 |
Correct |
87 ms |
6480 KB |
Output is correct |
23 |
Correct |
79 ms |
7756 KB |
Output is correct |
24 |
Correct |
121 ms |
18812 KB |
Output is correct |
25 |
Correct |
118 ms |
18772 KB |
Output is correct |
26 |
Correct |
89 ms |
20268 KB |
Output is correct |
27 |
Correct |
100 ms |
20172 KB |
Output is correct |
28 |
Correct |
89 ms |
18172 KB |
Output is correct |
29 |
Correct |
102 ms |
19676 KB |
Output is correct |
30 |
Correct |
113 ms |
18768 KB |
Output is correct |
31 |
Correct |
113 ms |
18768 KB |
Output is correct |
32 |
Correct |
112 ms |
19060 KB |
Output is correct |
33 |
Correct |
96 ms |
19284 KB |
Output is correct |
34 |
Correct |
121 ms |
19092 KB |
Output is correct |
35 |
Correct |
111 ms |
18892 KB |
Output is correct |
36 |
Correct |
103 ms |
19280 KB |
Output is correct |
37 |
Correct |
92 ms |
18856 KB |
Output is correct |
38 |
Correct |
103 ms |
18844 KB |
Output is correct |
39 |
Correct |
74 ms |
19024 KB |
Output is correct |
40 |
Correct |
84 ms |
18516 KB |
Output is correct |
41 |
Correct |
74 ms |
18772 KB |
Output is correct |
42 |
Correct |
72 ms |
18592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
452 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
604 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 |
600 KB |
Output is correct |
17 |
Correct |
2 ms |
604 KB |
Output is correct |
18 |
Correct |
2 ms |
604 KB |
Output is correct |
19 |
Correct |
2 ms |
600 KB |
Output is correct |
20 |
Correct |
2 ms |
736 KB |
Output is correct |
21 |
Correct |
3 ms |
604 KB |
Output is correct |
22 |
Correct |
171 ms |
20204 KB |
Output is correct |
23 |
Correct |
203 ms |
20936 KB |
Output is correct |
24 |
Correct |
202 ms |
22360 KB |
Output is correct |
25 |
Correct |
335 ms |
28952 KB |
Output is correct |
26 |
Correct |
182 ms |
20640 KB |
Output is correct |
27 |
Correct |
309 ms |
29012 KB |
Output is correct |
28 |
Correct |
316 ms |
28928 KB |
Output is correct |
29 |
Correct |
162 ms |
20308 KB |
Output is correct |
30 |
Correct |
119 ms |
20048 KB |
Output is correct |
31 |
Correct |
137 ms |
21076 KB |
Output is correct |
32 |
Correct |
262 ms |
28500 KB |
Output is correct |
33 |
Correct |
149 ms |
20096 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 |
724 KB |
Output is correct |
39 |
Correct |
2 ms |
604 KB |
Output is correct |
40 |
Correct |
2 ms |
680 KB |
Output is correct |
41 |
Correct |
126 ms |
20048 KB |
Output is correct |
42 |
Correct |
133 ms |
20868 KB |
Output is correct |
43 |
Correct |
264 ms |
28376 KB |
Output is correct |
44 |
Correct |
139 ms |
20308 KB |
Output is correct |
45 |
Correct |
98 ms |
18772 KB |
Output is correct |
46 |
Correct |
102 ms |
18772 KB |
Output is correct |
47 |
Correct |
76 ms |
18980 KB |
Output is correct |
48 |
Correct |
81 ms |
18700 KB |
Output is correct |
49 |
Correct |
84 ms |
18916 KB |
Output is correct |
50 |
Correct |
83 ms |
18512 KB |
Output is correct |
51 |
Correct |
643 ms |
91912 KB |
Output is correct |
52 |
Correct |
634 ms |
91916 KB |
Output is correct |
53 |
Correct |
453 ms |
92404 KB |
Output is correct |
54 |
Correct |
462 ms |
91728 KB |
Output is correct |
55 |
Correct |
451 ms |
91056 KB |
Output is correct |
56 |
Correct |
87 ms |
6480 KB |
Output is correct |
57 |
Correct |
79 ms |
7756 KB |
Output is correct |
58 |
Correct |
121 ms |
18812 KB |
Output is correct |
59 |
Correct |
118 ms |
18772 KB |
Output is correct |
60 |
Correct |
89 ms |
20268 KB |
Output is correct |
61 |
Correct |
100 ms |
20172 KB |
Output is correct |
62 |
Correct |
89 ms |
18172 KB |
Output is correct |
63 |
Correct |
102 ms |
19676 KB |
Output is correct |
64 |
Correct |
113 ms |
18768 KB |
Output is correct |
65 |
Correct |
113 ms |
18768 KB |
Output is correct |
66 |
Correct |
112 ms |
19060 KB |
Output is correct |
67 |
Correct |
96 ms |
19284 KB |
Output is correct |
68 |
Correct |
121 ms |
19092 KB |
Output is correct |
69 |
Correct |
111 ms |
18892 KB |
Output is correct |
70 |
Correct |
103 ms |
19280 KB |
Output is correct |
71 |
Correct |
92 ms |
18856 KB |
Output is correct |
72 |
Correct |
103 ms |
18844 KB |
Output is correct |
73 |
Correct |
74 ms |
19024 KB |
Output is correct |
74 |
Correct |
84 ms |
18516 KB |
Output is correct |
75 |
Correct |
74 ms |
18772 KB |
Output is correct |
76 |
Correct |
72 ms |
18592 KB |
Output is correct |
77 |
Correct |
775 ms |
93264 KB |
Output is correct |
78 |
Correct |
792 ms |
86272 KB |
Output is correct |
79 |
Correct |
619 ms |
92268 KB |
Output is correct |
80 |
Correct |
645 ms |
92240 KB |
Output is correct |
81 |
Correct |
622 ms |
90708 KB |
Output is correct |
82 |
Correct |
594 ms |
91448 KB |
Output is correct |
83 |
Correct |
787 ms |
86408 KB |
Output is correct |
84 |
Correct |
812 ms |
86272 KB |
Output is correct |
85 |
Correct |
659 ms |
87156 KB |
Output is correct |
86 |
Correct |
689 ms |
85988 KB |
Output is correct |
87 |
Correct |
669 ms |
86128 KB |
Output is correct |
88 |
Correct |
638 ms |
90852 KB |
Output is correct |