#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define getbit(x, i) (((x) >> (i)) & 1)
#define bit(x) (1 << (x))
#define popcount __builtin_popcountll
mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
long long rand(long long l, long long r) {
return l + rd() % (r - l + 1);
}
const int N = 1e6 + 5;
const int mod = 1e9 + 7; // 998244353;
const int lg = 25; // lg + 1
const int inf = 1e9; // INT_MAX;
const long long llinf = 1e18; // LLONG_MAX;
template<class X, class Y>
bool minimize(X &a, Y b) {
return a > b ? (a = b, true) : false;
}
template<class X, class Y>
bool maximize(X &a, Y b) {
return a < b ? (a = b, true) : false;
}
template<class X, class Y>
bool add(X &a, Y b) {
a += b;
while (a >= mod) a -= mod;
while (a < 0) a += mod;
return true;
}
struct node {
int L, R, M, val;
int lazy = 0;
node *l, *r;
node (int _L, int _R) : L(_L), R(_R) {
M = (L + R) >> 1;
val = 0;
if (L < R) {
l = new node(L, M);
r = new node(M + 1, R);
}
}
void down() {
l->lazy = max(l->lazy, lazy);
r->lazy = max(r->lazy, lazy);
l->val = max(l->val, lazy);
r->val = max(r->val, lazy);
}
void update(int u, int v, int c) {
if (v < L || u > R) return;
if (u <= L && R <= v) {
lazy = max(lazy, c);
val = max(val, c);
return;
}
down();
l->update(u, v, c);
r->update(u, v, c);
val = min(l->val, r->val);
}
int get(int u, int v) {
if (v < L || u > R)
return inf;
if (u <= L && R <= v)
return val;
down();
return min(l->get(u, v), r->get(u, v));
}
} *root;
struct SegmentTree {
int n;
vector<int> val, lazy;
void init(int _n) {
n = _n;
val.assign(n * 4 + 5, 0);
lazy.assign(n * 4 + 5, 0);
}
void down(int i) {
for (int j = i * 2; j <= i * 2 + 1; ++j) {
val[j] = max(val[j], lazy[i]);
lazy[j] = max(lazy[j], lazy[i]);
}
}
void update(int i, int L, int R, int l, int r, int c) {
if (r < L || l > R)
return;
if (l <= L && R <= r) {
val[i] = max(val[i], c);
lazy[i] = max(lazy[i], c);
return;
}
down(i);
int M = (L + R) >> 1;
update(i << 1, L, M, l, r, c);
update(i << 1 | 1, M + 1, R, l, r, c);
val[i] = min(val[i << 1], val[i << 1 | 1]);
}
int get(int i, int L, int R, int l, int r) {
if (r < L || l > R)
return inf;
if (l <= L && R <= r)
return val[i];
down(i);
int M = (L + R) >> 1;
return min(get(i << 1, L, M, l, r),
get(i << 1 | 1, M + 1, R, l, r));
}
void update(int l, int r, int c) {
update(1, 1, n, l, r, c);
}
int get(int l, int r) {
return get(1, 1, n, l, r);
}
} t;
int n, m, q;
vector<int> curtain[N];
vector<pair<int, int> > query[N];
int ans[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m >> q;
for (int i = 1; i <= m; ++i) {
int l, r;
cin >> l >> r;
curtain[r].push_back(l);
}
for (int i = 1; i <= q; ++i) {
int s, e;
cin >> s >> e;
query[e].emplace_back(s, i);
}
t.init(n);
root = new node(1, n);
for (int r = 1; r <= n; ++ r) {
for (int l : curtain[r]) {
// root->update(l, r, l);
t.update(l, r, l);
}
for (auto [l, id] : query[r]) {
// ans[id] = root->get(l, r) >= l;
ans[id] = t.get(l, r) >= l;
}
}
for (int i = 1; i <= q; ++i)
cout << (ans[i] ? "YES" : "NO") << '\n';
// for (int i = 1; i <= n; ++i)
// cout << root->get(i, i) << ' ';
return 0;
}
/*
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
48984 KB |
Output is correct |
2 |
Correct |
10 ms |
48988 KB |
Output is correct |
3 |
Correct |
11 ms |
48988 KB |
Output is correct |
4 |
Correct |
12 ms |
48988 KB |
Output is correct |
5 |
Correct |
10 ms |
48988 KB |
Output is correct |
6 |
Correct |
11 ms |
48988 KB |
Output is correct |
7 |
Correct |
11 ms |
49332 KB |
Output is correct |
8 |
Correct |
10 ms |
48984 KB |
Output is correct |
9 |
Correct |
11 ms |
48988 KB |
Output is correct |
10 |
Correct |
10 ms |
48988 KB |
Output is correct |
11 |
Correct |
11 ms |
49044 KB |
Output is correct |
12 |
Correct |
11 ms |
48984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
48984 KB |
Output is correct |
2 |
Correct |
10 ms |
48988 KB |
Output is correct |
3 |
Correct |
11 ms |
48988 KB |
Output is correct |
4 |
Correct |
12 ms |
48988 KB |
Output is correct |
5 |
Correct |
10 ms |
48988 KB |
Output is correct |
6 |
Correct |
11 ms |
48988 KB |
Output is correct |
7 |
Correct |
11 ms |
49332 KB |
Output is correct |
8 |
Correct |
10 ms |
48984 KB |
Output is correct |
9 |
Correct |
11 ms |
48988 KB |
Output is correct |
10 |
Correct |
10 ms |
48988 KB |
Output is correct |
11 |
Correct |
11 ms |
49044 KB |
Output is correct |
12 |
Correct |
11 ms |
48984 KB |
Output is correct |
13 |
Correct |
12 ms |
49244 KB |
Output is correct |
14 |
Correct |
14 ms |
49500 KB |
Output is correct |
15 |
Correct |
15 ms |
49496 KB |
Output is correct |
16 |
Correct |
12 ms |
49496 KB |
Output is correct |
17 |
Correct |
12 ms |
49500 KB |
Output is correct |
18 |
Correct |
14 ms |
49568 KB |
Output is correct |
19 |
Correct |
12 ms |
49500 KB |
Output is correct |
20 |
Correct |
12 ms |
49500 KB |
Output is correct |
21 |
Correct |
12 ms |
49500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
48984 KB |
Output is correct |
2 |
Correct |
10 ms |
48988 KB |
Output is correct |
3 |
Correct |
11 ms |
48988 KB |
Output is correct |
4 |
Correct |
12 ms |
48988 KB |
Output is correct |
5 |
Correct |
10 ms |
48988 KB |
Output is correct |
6 |
Correct |
11 ms |
48988 KB |
Output is correct |
7 |
Correct |
11 ms |
49332 KB |
Output is correct |
8 |
Correct |
10 ms |
48984 KB |
Output is correct |
9 |
Correct |
11 ms |
48988 KB |
Output is correct |
10 |
Correct |
10 ms |
48988 KB |
Output is correct |
11 |
Correct |
11 ms |
49044 KB |
Output is correct |
12 |
Correct |
11 ms |
48984 KB |
Output is correct |
13 |
Correct |
12 ms |
49244 KB |
Output is correct |
14 |
Correct |
14 ms |
49500 KB |
Output is correct |
15 |
Correct |
15 ms |
49496 KB |
Output is correct |
16 |
Correct |
12 ms |
49496 KB |
Output is correct |
17 |
Correct |
12 ms |
49500 KB |
Output is correct |
18 |
Correct |
14 ms |
49568 KB |
Output is correct |
19 |
Correct |
12 ms |
49500 KB |
Output is correct |
20 |
Correct |
12 ms |
49500 KB |
Output is correct |
21 |
Correct |
12 ms |
49500 KB |
Output is correct |
22 |
Correct |
159 ms |
63484 KB |
Output is correct |
23 |
Correct |
163 ms |
63928 KB |
Output is correct |
24 |
Correct |
206 ms |
65384 KB |
Output is correct |
25 |
Correct |
316 ms |
70996 KB |
Output is correct |
26 |
Correct |
163 ms |
63588 KB |
Output is correct |
27 |
Correct |
345 ms |
70968 KB |
Output is correct |
28 |
Correct |
348 ms |
70992 KB |
Output is correct |
29 |
Correct |
153 ms |
62572 KB |
Output is correct |
30 |
Correct |
125 ms |
62800 KB |
Output is correct |
31 |
Correct |
130 ms |
63520 KB |
Output is correct |
32 |
Correct |
289 ms |
70104 KB |
Output is correct |
33 |
Correct |
112 ms |
62936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
48984 KB |
Output is correct |
2 |
Correct |
11 ms |
48988 KB |
Output is correct |
3 |
Correct |
10 ms |
48988 KB |
Output is correct |
4 |
Correct |
12 ms |
48984 KB |
Output is correct |
5 |
Correct |
13 ms |
49392 KB |
Output is correct |
6 |
Correct |
12 ms |
49356 KB |
Output is correct |
7 |
Correct |
12 ms |
49496 KB |
Output is correct |
8 |
Correct |
113 ms |
62824 KB |
Output is correct |
9 |
Correct |
132 ms |
63712 KB |
Output is correct |
10 |
Correct |
276 ms |
70084 KB |
Output is correct |
11 |
Correct |
110 ms |
62968 KB |
Output is correct |
12 |
Correct |
119 ms |
70952 KB |
Output is correct |
13 |
Correct |
116 ms |
70996 KB |
Output is correct |
14 |
Correct |
100 ms |
70992 KB |
Output is correct |
15 |
Correct |
95 ms |
70580 KB |
Output is correct |
16 |
Correct |
98 ms |
71072 KB |
Output is correct |
17 |
Correct |
124 ms |
70740 KB |
Output is correct |
18 |
Correct |
699 ms |
151312 KB |
Output is correct |
19 |
Correct |
742 ms |
151064 KB |
Output is correct |
20 |
Correct |
574 ms |
152100 KB |
Output is correct |
21 |
Correct |
551 ms |
150908 KB |
Output is correct |
22 |
Correct |
590 ms |
150280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
48984 KB |
Output is correct |
2 |
Correct |
10 ms |
48988 KB |
Output is correct |
3 |
Correct |
11 ms |
48988 KB |
Output is correct |
4 |
Correct |
12 ms |
48988 KB |
Output is correct |
5 |
Correct |
10 ms |
48988 KB |
Output is correct |
6 |
Correct |
11 ms |
48988 KB |
Output is correct |
7 |
Correct |
11 ms |
49332 KB |
Output is correct |
8 |
Correct |
10 ms |
48984 KB |
Output is correct |
9 |
Correct |
11 ms |
48988 KB |
Output is correct |
10 |
Correct |
10 ms |
48988 KB |
Output is correct |
11 |
Correct |
11 ms |
49044 KB |
Output is correct |
12 |
Correct |
11 ms |
48984 KB |
Output is correct |
13 |
Correct |
12 ms |
49244 KB |
Output is correct |
14 |
Correct |
14 ms |
49500 KB |
Output is correct |
15 |
Correct |
15 ms |
49496 KB |
Output is correct |
16 |
Correct |
12 ms |
49496 KB |
Output is correct |
17 |
Correct |
12 ms |
49500 KB |
Output is correct |
18 |
Correct |
14 ms |
49568 KB |
Output is correct |
19 |
Correct |
12 ms |
49500 KB |
Output is correct |
20 |
Correct |
12 ms |
49500 KB |
Output is correct |
21 |
Correct |
12 ms |
49500 KB |
Output is correct |
22 |
Correct |
99 ms |
56916 KB |
Output is correct |
23 |
Correct |
92 ms |
56772 KB |
Output is correct |
24 |
Correct |
140 ms |
70224 KB |
Output is correct |
25 |
Correct |
131 ms |
70200 KB |
Output is correct |
26 |
Correct |
119 ms |
71508 KB |
Output is correct |
27 |
Correct |
125 ms |
71476 KB |
Output is correct |
28 |
Correct |
94 ms |
69208 KB |
Output is correct |
29 |
Correct |
112 ms |
71004 KB |
Output is correct |
30 |
Correct |
134 ms |
70228 KB |
Output is correct |
31 |
Correct |
131 ms |
70216 KB |
Output is correct |
32 |
Correct |
119 ms |
70628 KB |
Output is correct |
33 |
Correct |
122 ms |
71252 KB |
Output is correct |
34 |
Correct |
125 ms |
69616 KB |
Output is correct |
35 |
Correct |
128 ms |
70036 KB |
Output is correct |
36 |
Correct |
132 ms |
70568 KB |
Output is correct |
37 |
Correct |
132 ms |
70944 KB |
Output is correct |
38 |
Correct |
117 ms |
70992 KB |
Output is correct |
39 |
Correct |
95 ms |
70992 KB |
Output is correct |
40 |
Correct |
94 ms |
70772 KB |
Output is correct |
41 |
Correct |
98 ms |
70996 KB |
Output is correct |
42 |
Correct |
99 ms |
70668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
48984 KB |
Output is correct |
2 |
Correct |
10 ms |
48988 KB |
Output is correct |
3 |
Correct |
11 ms |
48988 KB |
Output is correct |
4 |
Correct |
12 ms |
48988 KB |
Output is correct |
5 |
Correct |
10 ms |
48988 KB |
Output is correct |
6 |
Correct |
11 ms |
48988 KB |
Output is correct |
7 |
Correct |
11 ms |
49332 KB |
Output is correct |
8 |
Correct |
10 ms |
48984 KB |
Output is correct |
9 |
Correct |
11 ms |
48988 KB |
Output is correct |
10 |
Correct |
10 ms |
48988 KB |
Output is correct |
11 |
Correct |
11 ms |
49044 KB |
Output is correct |
12 |
Correct |
11 ms |
48984 KB |
Output is correct |
13 |
Correct |
12 ms |
49244 KB |
Output is correct |
14 |
Correct |
14 ms |
49500 KB |
Output is correct |
15 |
Correct |
15 ms |
49496 KB |
Output is correct |
16 |
Correct |
12 ms |
49496 KB |
Output is correct |
17 |
Correct |
12 ms |
49500 KB |
Output is correct |
18 |
Correct |
14 ms |
49568 KB |
Output is correct |
19 |
Correct |
12 ms |
49500 KB |
Output is correct |
20 |
Correct |
12 ms |
49500 KB |
Output is correct |
21 |
Correct |
12 ms |
49500 KB |
Output is correct |
22 |
Correct |
159 ms |
63484 KB |
Output is correct |
23 |
Correct |
163 ms |
63928 KB |
Output is correct |
24 |
Correct |
206 ms |
65384 KB |
Output is correct |
25 |
Correct |
316 ms |
70996 KB |
Output is correct |
26 |
Correct |
163 ms |
63588 KB |
Output is correct |
27 |
Correct |
345 ms |
70968 KB |
Output is correct |
28 |
Correct |
348 ms |
70992 KB |
Output is correct |
29 |
Correct |
153 ms |
62572 KB |
Output is correct |
30 |
Correct |
125 ms |
62800 KB |
Output is correct |
31 |
Correct |
130 ms |
63520 KB |
Output is correct |
32 |
Correct |
289 ms |
70104 KB |
Output is correct |
33 |
Correct |
112 ms |
62936 KB |
Output is correct |
34 |
Correct |
11 ms |
48984 KB |
Output is correct |
35 |
Correct |
11 ms |
48988 KB |
Output is correct |
36 |
Correct |
10 ms |
48988 KB |
Output is correct |
37 |
Correct |
12 ms |
48984 KB |
Output is correct |
38 |
Correct |
13 ms |
49392 KB |
Output is correct |
39 |
Correct |
12 ms |
49356 KB |
Output is correct |
40 |
Correct |
12 ms |
49496 KB |
Output is correct |
41 |
Correct |
113 ms |
62824 KB |
Output is correct |
42 |
Correct |
132 ms |
63712 KB |
Output is correct |
43 |
Correct |
276 ms |
70084 KB |
Output is correct |
44 |
Correct |
110 ms |
62968 KB |
Output is correct |
45 |
Correct |
119 ms |
70952 KB |
Output is correct |
46 |
Correct |
116 ms |
70996 KB |
Output is correct |
47 |
Correct |
100 ms |
70992 KB |
Output is correct |
48 |
Correct |
95 ms |
70580 KB |
Output is correct |
49 |
Correct |
98 ms |
71072 KB |
Output is correct |
50 |
Correct |
124 ms |
70740 KB |
Output is correct |
51 |
Correct |
699 ms |
151312 KB |
Output is correct |
52 |
Correct |
742 ms |
151064 KB |
Output is correct |
53 |
Correct |
574 ms |
152100 KB |
Output is correct |
54 |
Correct |
551 ms |
150908 KB |
Output is correct |
55 |
Correct |
590 ms |
150280 KB |
Output is correct |
56 |
Correct |
99 ms |
56916 KB |
Output is correct |
57 |
Correct |
92 ms |
56772 KB |
Output is correct |
58 |
Correct |
140 ms |
70224 KB |
Output is correct |
59 |
Correct |
131 ms |
70200 KB |
Output is correct |
60 |
Correct |
119 ms |
71508 KB |
Output is correct |
61 |
Correct |
125 ms |
71476 KB |
Output is correct |
62 |
Correct |
94 ms |
69208 KB |
Output is correct |
63 |
Correct |
112 ms |
71004 KB |
Output is correct |
64 |
Correct |
134 ms |
70228 KB |
Output is correct |
65 |
Correct |
131 ms |
70216 KB |
Output is correct |
66 |
Correct |
119 ms |
70628 KB |
Output is correct |
67 |
Correct |
122 ms |
71252 KB |
Output is correct |
68 |
Correct |
125 ms |
69616 KB |
Output is correct |
69 |
Correct |
128 ms |
70036 KB |
Output is correct |
70 |
Correct |
132 ms |
70568 KB |
Output is correct |
71 |
Correct |
132 ms |
70944 KB |
Output is correct |
72 |
Correct |
117 ms |
70992 KB |
Output is correct |
73 |
Correct |
95 ms |
70992 KB |
Output is correct |
74 |
Correct |
94 ms |
70772 KB |
Output is correct |
75 |
Correct |
98 ms |
70996 KB |
Output is correct |
76 |
Correct |
99 ms |
70668 KB |
Output is correct |
77 |
Correct |
804 ms |
147792 KB |
Output is correct |
78 |
Correct |
822 ms |
147876 KB |
Output is correct |
79 |
Correct |
682 ms |
154452 KB |
Output is correct |
80 |
Correct |
708 ms |
154352 KB |
Output is correct |
81 |
Correct |
656 ms |
152148 KB |
Output is correct |
82 |
Correct |
668 ms |
153432 KB |
Output is correct |
83 |
Correct |
801 ms |
147888 KB |
Output is correct |
84 |
Correct |
799 ms |
147664 KB |
Output is correct |
85 |
Correct |
746 ms |
149328 KB |
Output is correct |
86 |
Correct |
715 ms |
145932 KB |
Output is correct |
87 |
Correct |
717 ms |
145824 KB |
Output is correct |
88 |
Correct |
678 ms |
152208 KB |
Output is correct |