#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define INF 1e9
using namespace std;
typedef long long ll;
vector<int>v[500005];
vector<pair<int, int>>a[500005];
const int MAXN = 1e6 + 5;
ll t[4 * MAXN], lazy[4 * MAXN];
void pushdown(int v) {
if (lazy[v] > 0) {
lazy[2 * v] = max(lazy[2*v], lazy[v]);
lazy[2 * v + 1] = max(lazy[2 * v + 1], lazy[v]);
t[2 * v] = max(t[2 * v], lazy[v]);
t[2 * v + 1] = max(t[2 * v + 1], lazy[v]);
lazy[v] = 0;
}
}
void upd(int v, int l, int r, int tl, int tr, ll val) {
if (l > r)return;
if (l == tl && r == tr) {
lazy[v] = max(lazy[v], val);
t[v] = max(t[v], val);
return;
}
pushdown(v);
int tm = (tl + tr) / 2;
upd(2 * v, l, min(r, tm), tl, tm, val);
upd(2 * v + 1, max(l, tm + 1), r, tm + 1, tr, val);
t[v] = min(t[v * 2], t[v * 2 + 1]);
}
ll query(int v, int tl, int tr, int l, int r) {
if (l > r)return INF;
if (l == tl && r == tr)return t[v];
pushdown(v);
int tm = (tl + tr) / 2;
return min(query(2 * v, tl, tm, l, min(r, tm)),
query(2 * v + 1, tm + 1, tr, max(l, tm + 1), r));
}
void solve()
{
int n, m, q; cin >> n >> m >> q;
vector<int>ans(q);
for (int i = 1; i <= m; i++) {
int l, r; cin >> l >> r;
v[r].push_back(l);
}
for (int i = 0; i < q; i++) {
int l, r; cin >> l >> r;
a[r].push_back({ l, i });
}
for (int i = 1; i <= n; i++) {
for (auto l : v[i]) {
upd(1, l, i, 1, n, l);
//cout << query(1, 1,n, l, i) << "\n";
}
for (auto l : a[i]) {
if (query(1, 1, n, l.first, i) < l.first) ans[l.second] = 0;
else ans[l.second] = 1;
}
}
for (int i = 0; i < q; i++) {
if (ans[i]) cout << "YES" << "\n";
else cout << "NO" << "\n";
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;// cin>>t;
while (t--) solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
24668 KB |
Output is correct |
2 |
Correct |
6 ms |
24668 KB |
Output is correct |
3 |
Correct |
6 ms |
24668 KB |
Output is correct |
4 |
Correct |
8 ms |
24668 KB |
Output is correct |
5 |
Correct |
7 ms |
24668 KB |
Output is correct |
6 |
Correct |
6 ms |
24664 KB |
Output is correct |
7 |
Correct |
6 ms |
24664 KB |
Output is correct |
8 |
Correct |
7 ms |
24668 KB |
Output is correct |
9 |
Correct |
6 ms |
24784 KB |
Output is correct |
10 |
Correct |
6 ms |
24668 KB |
Output is correct |
11 |
Correct |
6 ms |
24668 KB |
Output is correct |
12 |
Correct |
6 ms |
24788 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
24668 KB |
Output is correct |
2 |
Correct |
6 ms |
24668 KB |
Output is correct |
3 |
Correct |
6 ms |
24668 KB |
Output is correct |
4 |
Correct |
8 ms |
24668 KB |
Output is correct |
5 |
Correct |
7 ms |
24668 KB |
Output is correct |
6 |
Correct |
6 ms |
24664 KB |
Output is correct |
7 |
Correct |
6 ms |
24664 KB |
Output is correct |
8 |
Correct |
7 ms |
24668 KB |
Output is correct |
9 |
Correct |
6 ms |
24784 KB |
Output is correct |
10 |
Correct |
6 ms |
24668 KB |
Output is correct |
11 |
Correct |
6 ms |
24668 KB |
Output is correct |
12 |
Correct |
6 ms |
24788 KB |
Output is correct |
13 |
Correct |
7 ms |
24924 KB |
Output is correct |
14 |
Correct |
7 ms |
24924 KB |
Output is correct |
15 |
Correct |
8 ms |
25016 KB |
Output is correct |
16 |
Correct |
8 ms |
24920 KB |
Output is correct |
17 |
Correct |
7 ms |
24924 KB |
Output is correct |
18 |
Correct |
7 ms |
24836 KB |
Output is correct |
19 |
Correct |
7 ms |
24924 KB |
Output is correct |
20 |
Correct |
7 ms |
24924 KB |
Output is correct |
21 |
Correct |
7 ms |
24924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
24668 KB |
Output is correct |
2 |
Correct |
6 ms |
24668 KB |
Output is correct |
3 |
Correct |
6 ms |
24668 KB |
Output is correct |
4 |
Correct |
8 ms |
24668 KB |
Output is correct |
5 |
Correct |
7 ms |
24668 KB |
Output is correct |
6 |
Correct |
6 ms |
24664 KB |
Output is correct |
7 |
Correct |
6 ms |
24664 KB |
Output is correct |
8 |
Correct |
7 ms |
24668 KB |
Output is correct |
9 |
Correct |
6 ms |
24784 KB |
Output is correct |
10 |
Correct |
6 ms |
24668 KB |
Output is correct |
11 |
Correct |
6 ms |
24668 KB |
Output is correct |
12 |
Correct |
6 ms |
24788 KB |
Output is correct |
13 |
Correct |
7 ms |
24924 KB |
Output is correct |
14 |
Correct |
7 ms |
24924 KB |
Output is correct |
15 |
Correct |
8 ms |
25016 KB |
Output is correct |
16 |
Correct |
8 ms |
24920 KB |
Output is correct |
17 |
Correct |
7 ms |
24924 KB |
Output is correct |
18 |
Correct |
7 ms |
24836 KB |
Output is correct |
19 |
Correct |
7 ms |
24924 KB |
Output is correct |
20 |
Correct |
7 ms |
24924 KB |
Output is correct |
21 |
Correct |
7 ms |
24924 KB |
Output is correct |
22 |
Correct |
165 ms |
38776 KB |
Output is correct |
23 |
Correct |
172 ms |
39248 KB |
Output is correct |
24 |
Correct |
203 ms |
40784 KB |
Output is correct |
25 |
Correct |
324 ms |
46416 KB |
Output is correct |
26 |
Correct |
176 ms |
39224 KB |
Output is correct |
27 |
Correct |
338 ms |
46436 KB |
Output is correct |
28 |
Correct |
323 ms |
46392 KB |
Output is correct |
29 |
Correct |
156 ms |
38144 KB |
Output is correct |
30 |
Correct |
112 ms |
38232 KB |
Output is correct |
31 |
Correct |
125 ms |
38992 KB |
Output is correct |
32 |
Correct |
268 ms |
45536 KB |
Output is correct |
33 |
Correct |
110 ms |
38380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
24668 KB |
Output is correct |
2 |
Correct |
6 ms |
24668 KB |
Output is correct |
3 |
Correct |
6 ms |
24664 KB |
Output is correct |
4 |
Correct |
6 ms |
24668 KB |
Output is correct |
5 |
Correct |
7 ms |
24836 KB |
Output is correct |
6 |
Correct |
7 ms |
24924 KB |
Output is correct |
7 |
Correct |
8 ms |
24836 KB |
Output is correct |
8 |
Correct |
111 ms |
38192 KB |
Output is correct |
9 |
Correct |
127 ms |
39088 KB |
Output is correct |
10 |
Correct |
273 ms |
45572 KB |
Output is correct |
11 |
Correct |
145 ms |
38236 KB |
Output is correct |
12 |
Correct |
105 ms |
36340 KB |
Output is correct |
13 |
Correct |
101 ms |
36332 KB |
Output is correct |
14 |
Correct |
88 ms |
36300 KB |
Output is correct |
15 |
Correct |
80 ms |
35924 KB |
Output is correct |
16 |
Correct |
90 ms |
36416 KB |
Output is correct |
17 |
Correct |
76 ms |
35920 KB |
Output is correct |
18 |
Correct |
731 ms |
80360 KB |
Output is correct |
19 |
Correct |
734 ms |
80616 KB |
Output is correct |
20 |
Correct |
512 ms |
80976 KB |
Output is correct |
21 |
Correct |
506 ms |
80208 KB |
Output is correct |
22 |
Correct |
543 ms |
79192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
24668 KB |
Output is correct |
2 |
Correct |
6 ms |
24668 KB |
Output is correct |
3 |
Correct |
6 ms |
24668 KB |
Output is correct |
4 |
Correct |
8 ms |
24668 KB |
Output is correct |
5 |
Correct |
7 ms |
24668 KB |
Output is correct |
6 |
Correct |
6 ms |
24664 KB |
Output is correct |
7 |
Correct |
6 ms |
24664 KB |
Output is correct |
8 |
Correct |
7 ms |
24668 KB |
Output is correct |
9 |
Correct |
6 ms |
24784 KB |
Output is correct |
10 |
Correct |
6 ms |
24668 KB |
Output is correct |
11 |
Correct |
6 ms |
24668 KB |
Output is correct |
12 |
Correct |
6 ms |
24788 KB |
Output is correct |
13 |
Correct |
7 ms |
24924 KB |
Output is correct |
14 |
Correct |
7 ms |
24924 KB |
Output is correct |
15 |
Correct |
8 ms |
25016 KB |
Output is correct |
16 |
Correct |
8 ms |
24920 KB |
Output is correct |
17 |
Correct |
7 ms |
24924 KB |
Output is correct |
18 |
Correct |
7 ms |
24836 KB |
Output is correct |
19 |
Correct |
7 ms |
24924 KB |
Output is correct |
20 |
Correct |
7 ms |
24924 KB |
Output is correct |
21 |
Correct |
7 ms |
24924 KB |
Output is correct |
22 |
Correct |
88 ms |
30028 KB |
Output is correct |
23 |
Correct |
96 ms |
29988 KB |
Output is correct |
24 |
Correct |
123 ms |
35668 KB |
Output is correct |
25 |
Correct |
121 ms |
35552 KB |
Output is correct |
26 |
Correct |
92 ms |
36296 KB |
Output is correct |
27 |
Correct |
114 ms |
36948 KB |
Output is correct |
28 |
Correct |
82 ms |
34664 KB |
Output is correct |
29 |
Correct |
92 ms |
35992 KB |
Output is correct |
30 |
Correct |
120 ms |
35660 KB |
Output is correct |
31 |
Correct |
134 ms |
35668 KB |
Output is correct |
32 |
Correct |
106 ms |
35920 KB |
Output is correct |
33 |
Correct |
99 ms |
36432 KB |
Output is correct |
34 |
Correct |
110 ms |
35156 KB |
Output is correct |
35 |
Correct |
116 ms |
35408 KB |
Output is correct |
36 |
Correct |
108 ms |
35956 KB |
Output is correct |
37 |
Correct |
101 ms |
36352 KB |
Output is correct |
38 |
Correct |
104 ms |
36736 KB |
Output is correct |
39 |
Correct |
82 ms |
36312 KB |
Output is correct |
40 |
Correct |
78 ms |
35892 KB |
Output is correct |
41 |
Correct |
77 ms |
36436 KB |
Output is correct |
42 |
Correct |
86 ms |
36040 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
24668 KB |
Output is correct |
2 |
Correct |
6 ms |
24668 KB |
Output is correct |
3 |
Correct |
6 ms |
24668 KB |
Output is correct |
4 |
Correct |
8 ms |
24668 KB |
Output is correct |
5 |
Correct |
7 ms |
24668 KB |
Output is correct |
6 |
Correct |
6 ms |
24664 KB |
Output is correct |
7 |
Correct |
6 ms |
24664 KB |
Output is correct |
8 |
Correct |
7 ms |
24668 KB |
Output is correct |
9 |
Correct |
6 ms |
24784 KB |
Output is correct |
10 |
Correct |
6 ms |
24668 KB |
Output is correct |
11 |
Correct |
6 ms |
24668 KB |
Output is correct |
12 |
Correct |
6 ms |
24788 KB |
Output is correct |
13 |
Correct |
7 ms |
24924 KB |
Output is correct |
14 |
Correct |
7 ms |
24924 KB |
Output is correct |
15 |
Correct |
8 ms |
25016 KB |
Output is correct |
16 |
Correct |
8 ms |
24920 KB |
Output is correct |
17 |
Correct |
7 ms |
24924 KB |
Output is correct |
18 |
Correct |
7 ms |
24836 KB |
Output is correct |
19 |
Correct |
7 ms |
24924 KB |
Output is correct |
20 |
Correct |
7 ms |
24924 KB |
Output is correct |
21 |
Correct |
7 ms |
24924 KB |
Output is correct |
22 |
Correct |
165 ms |
38776 KB |
Output is correct |
23 |
Correct |
172 ms |
39248 KB |
Output is correct |
24 |
Correct |
203 ms |
40784 KB |
Output is correct |
25 |
Correct |
324 ms |
46416 KB |
Output is correct |
26 |
Correct |
176 ms |
39224 KB |
Output is correct |
27 |
Correct |
338 ms |
46436 KB |
Output is correct |
28 |
Correct |
323 ms |
46392 KB |
Output is correct |
29 |
Correct |
156 ms |
38144 KB |
Output is correct |
30 |
Correct |
112 ms |
38232 KB |
Output is correct |
31 |
Correct |
125 ms |
38992 KB |
Output is correct |
32 |
Correct |
268 ms |
45536 KB |
Output is correct |
33 |
Correct |
110 ms |
38380 KB |
Output is correct |
34 |
Correct |
6 ms |
24668 KB |
Output is correct |
35 |
Correct |
6 ms |
24668 KB |
Output is correct |
36 |
Correct |
6 ms |
24664 KB |
Output is correct |
37 |
Correct |
6 ms |
24668 KB |
Output is correct |
38 |
Correct |
7 ms |
24836 KB |
Output is correct |
39 |
Correct |
7 ms |
24924 KB |
Output is correct |
40 |
Correct |
8 ms |
24836 KB |
Output is correct |
41 |
Correct |
111 ms |
38192 KB |
Output is correct |
42 |
Correct |
127 ms |
39088 KB |
Output is correct |
43 |
Correct |
273 ms |
45572 KB |
Output is correct |
44 |
Correct |
145 ms |
38236 KB |
Output is correct |
45 |
Correct |
105 ms |
36340 KB |
Output is correct |
46 |
Correct |
101 ms |
36332 KB |
Output is correct |
47 |
Correct |
88 ms |
36300 KB |
Output is correct |
48 |
Correct |
80 ms |
35924 KB |
Output is correct |
49 |
Correct |
90 ms |
36416 KB |
Output is correct |
50 |
Correct |
76 ms |
35920 KB |
Output is correct |
51 |
Correct |
731 ms |
80360 KB |
Output is correct |
52 |
Correct |
734 ms |
80616 KB |
Output is correct |
53 |
Correct |
512 ms |
80976 KB |
Output is correct |
54 |
Correct |
506 ms |
80208 KB |
Output is correct |
55 |
Correct |
543 ms |
79192 KB |
Output is correct |
56 |
Correct |
88 ms |
30028 KB |
Output is correct |
57 |
Correct |
96 ms |
29988 KB |
Output is correct |
58 |
Correct |
123 ms |
35668 KB |
Output is correct |
59 |
Correct |
121 ms |
35552 KB |
Output is correct |
60 |
Correct |
92 ms |
36296 KB |
Output is correct |
61 |
Correct |
114 ms |
36948 KB |
Output is correct |
62 |
Correct |
82 ms |
34664 KB |
Output is correct |
63 |
Correct |
92 ms |
35992 KB |
Output is correct |
64 |
Correct |
120 ms |
35660 KB |
Output is correct |
65 |
Correct |
134 ms |
35668 KB |
Output is correct |
66 |
Correct |
106 ms |
35920 KB |
Output is correct |
67 |
Correct |
99 ms |
36432 KB |
Output is correct |
68 |
Correct |
110 ms |
35156 KB |
Output is correct |
69 |
Correct |
116 ms |
35408 KB |
Output is correct |
70 |
Correct |
108 ms |
35956 KB |
Output is correct |
71 |
Correct |
101 ms |
36352 KB |
Output is correct |
72 |
Correct |
104 ms |
36736 KB |
Output is correct |
73 |
Correct |
82 ms |
36312 KB |
Output is correct |
74 |
Correct |
78 ms |
35892 KB |
Output is correct |
75 |
Correct |
77 ms |
36436 KB |
Output is correct |
76 |
Correct |
86 ms |
36040 KB |
Output is correct |
77 |
Correct |
927 ms |
77296 KB |
Output is correct |
78 |
Correct |
916 ms |
77084 KB |
Output is correct |
79 |
Correct |
629 ms |
81804 KB |
Output is correct |
80 |
Correct |
628 ms |
83276 KB |
Output is correct |
81 |
Correct |
597 ms |
80724 KB |
Output is correct |
82 |
Correct |
670 ms |
80724 KB |
Output is correct |
83 |
Correct |
826 ms |
77140 KB |
Output is correct |
84 |
Correct |
776 ms |
76884 KB |
Output is correct |
85 |
Correct |
731 ms |
78932 KB |
Output is correct |
86 |
Correct |
710 ms |
75472 KB |
Output is correct |
87 |
Correct |
701 ms |
75008 KB |
Output is correct |
88 |
Correct |
685 ms |
82016 KB |
Output is correct |