#include<bits/stdc++.h>
using namespace std;
namespace Solve
{
typedef pair<long long, long long> ox;
vector<int> events[1000001];
vector<ox> query[1000001];
#define fi first
#define se second
long long lazy[2000001], node[2000001];
bool res[1000001];
int n, m, q;
void down(int id, int l, int r)
{
if(lazy[id] == 0) return;
node[id] = max(node[id], lazy[id]);
if(l != r)
{
lazy[id * 2] = max(lazy[id * 2], lazy[id]);
lazy[id * 2 + 1] = max(lazy[id * 2 + 1], lazy[id]);
}
lazy[id] = 0;
}
void update(int id, int l, int r, int L, int R, int val)
{
down(id, l, r);
if(l > R || r < L) return;
if(L <= l && r <= R)
{
lazy[id] = val;
down(id, l, r);
return;
}
update(id * 2, l, (l + r)/2, L, R, val);
update(id * 2 + 1, (l + r)/2 + 1, r, L, R, val);
node[id] = min(node[id * 2], node[id * 2 + 1]);
}
int get(int id, int l, int r, int L, int R)
{
down(id, l, r);
if(l > R || r < L) return 1e9;
if(L <= l && r <= R)
{
return node[id];
}
return min(get(id * 2, l, (l + r)/2, L, R), get(id * 2 + 1, (l + r)/2 + 1, r, L, R));
}
void solve()
{
cin >> n >> m >> q;
for(int i = 1; i <= m ;i++)
{
int l, r;
cin >> l >> r;
events[r].push_back(l);
}
for(int i = 1; i <= q; i++)
{
int l, r;
cin >> l >> r;
query[r].push_back({l, i});
}
for(int r = 1; r <= n; r++)
{
for(auto l: events[r])
{
update(1, 1, n, l, r, l);
}
for(auto it: query[r])
{
int l = it.fi;
int id = it.se;
if(get(1, 1, n, l, r) >= l)
{
res[id] = 1;
}
}
}
for(int i = 1; i <= q; i++)
{
cout << (res[i] ? "YES\n" : "NO\n");
}
}
}
int main()
{
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
Solve::solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
48728 KB |
Output is correct |
2 |
Correct |
10 ms |
48708 KB |
Output is correct |
3 |
Correct |
10 ms |
48732 KB |
Output is correct |
4 |
Correct |
11 ms |
48692 KB |
Output is correct |
5 |
Correct |
11 ms |
48732 KB |
Output is correct |
6 |
Correct |
12 ms |
48692 KB |
Output is correct |
7 |
Correct |
11 ms |
48732 KB |
Output is correct |
8 |
Correct |
11 ms |
48792 KB |
Output is correct |
9 |
Correct |
10 ms |
48732 KB |
Output is correct |
10 |
Correct |
10 ms |
48732 KB |
Output is correct |
11 |
Correct |
10 ms |
48732 KB |
Output is correct |
12 |
Correct |
12 ms |
48732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
48728 KB |
Output is correct |
2 |
Correct |
10 ms |
48708 KB |
Output is correct |
3 |
Correct |
10 ms |
48732 KB |
Output is correct |
4 |
Correct |
11 ms |
48692 KB |
Output is correct |
5 |
Correct |
11 ms |
48732 KB |
Output is correct |
6 |
Correct |
12 ms |
48692 KB |
Output is correct |
7 |
Correct |
11 ms |
48732 KB |
Output is correct |
8 |
Correct |
11 ms |
48792 KB |
Output is correct |
9 |
Correct |
10 ms |
48732 KB |
Output is correct |
10 |
Correct |
10 ms |
48732 KB |
Output is correct |
11 |
Correct |
10 ms |
48732 KB |
Output is correct |
12 |
Correct |
12 ms |
48732 KB |
Output is correct |
13 |
Correct |
12 ms |
48732 KB |
Output is correct |
14 |
Correct |
13 ms |
48732 KB |
Output is correct |
15 |
Correct |
12 ms |
48732 KB |
Output is correct |
16 |
Correct |
12 ms |
48936 KB |
Output is correct |
17 |
Correct |
12 ms |
48732 KB |
Output is correct |
18 |
Correct |
11 ms |
48944 KB |
Output is correct |
19 |
Correct |
12 ms |
48728 KB |
Output is correct |
20 |
Correct |
14 ms |
48912 KB |
Output is correct |
21 |
Correct |
12 ms |
48728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
48728 KB |
Output is correct |
2 |
Correct |
10 ms |
48708 KB |
Output is correct |
3 |
Correct |
10 ms |
48732 KB |
Output is correct |
4 |
Correct |
11 ms |
48692 KB |
Output is correct |
5 |
Correct |
11 ms |
48732 KB |
Output is correct |
6 |
Correct |
12 ms |
48692 KB |
Output is correct |
7 |
Correct |
11 ms |
48732 KB |
Output is correct |
8 |
Correct |
11 ms |
48792 KB |
Output is correct |
9 |
Correct |
10 ms |
48732 KB |
Output is correct |
10 |
Correct |
10 ms |
48732 KB |
Output is correct |
11 |
Correct |
10 ms |
48732 KB |
Output is correct |
12 |
Correct |
12 ms |
48732 KB |
Output is correct |
13 |
Correct |
12 ms |
48732 KB |
Output is correct |
14 |
Correct |
13 ms |
48732 KB |
Output is correct |
15 |
Correct |
12 ms |
48732 KB |
Output is correct |
16 |
Correct |
12 ms |
48936 KB |
Output is correct |
17 |
Correct |
12 ms |
48732 KB |
Output is correct |
18 |
Correct |
11 ms |
48944 KB |
Output is correct |
19 |
Correct |
12 ms |
48728 KB |
Output is correct |
20 |
Correct |
14 ms |
48912 KB |
Output is correct |
21 |
Correct |
12 ms |
48728 KB |
Output is correct |
22 |
Correct |
191 ms |
62892 KB |
Output is correct |
23 |
Correct |
190 ms |
63140 KB |
Output is correct |
24 |
Correct |
225 ms |
63824 KB |
Output is correct |
25 |
Correct |
370 ms |
65928 KB |
Output is correct |
26 |
Correct |
189 ms |
63068 KB |
Output is correct |
27 |
Correct |
374 ms |
66064 KB |
Output is correct |
28 |
Correct |
380 ms |
66128 KB |
Output is correct |
29 |
Correct |
174 ms |
61600 KB |
Output is correct |
30 |
Correct |
124 ms |
63756 KB |
Output is correct |
31 |
Correct |
137 ms |
64076 KB |
Output is correct |
32 |
Correct |
298 ms |
66940 KB |
Output is correct |
33 |
Correct |
123 ms |
63604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
48728 KB |
Output is correct |
2 |
Correct |
11 ms |
48792 KB |
Output is correct |
3 |
Correct |
11 ms |
48732 KB |
Output is correct |
4 |
Correct |
10 ms |
48984 KB |
Output is correct |
5 |
Correct |
12 ms |
48984 KB |
Output is correct |
6 |
Correct |
12 ms |
48732 KB |
Output is correct |
7 |
Correct |
12 ms |
48732 KB |
Output is correct |
8 |
Correct |
119 ms |
63772 KB |
Output is correct |
9 |
Correct |
138 ms |
64080 KB |
Output is correct |
10 |
Correct |
298 ms |
66900 KB |
Output is correct |
11 |
Correct |
125 ms |
63864 KB |
Output is correct |
12 |
Correct |
114 ms |
58196 KB |
Output is correct |
13 |
Correct |
114 ms |
58172 KB |
Output is correct |
14 |
Correct |
89 ms |
58148 KB |
Output is correct |
15 |
Correct |
89 ms |
57680 KB |
Output is correct |
16 |
Correct |
91 ms |
58032 KB |
Output is correct |
17 |
Correct |
89 ms |
57684 KB |
Output is correct |
18 |
Correct |
710 ms |
92184 KB |
Output is correct |
19 |
Correct |
726 ms |
92060 KB |
Output is correct |
20 |
Correct |
548 ms |
92460 KB |
Output is correct |
21 |
Correct |
528 ms |
91588 KB |
Output is correct |
22 |
Correct |
530 ms |
90632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
48728 KB |
Output is correct |
2 |
Correct |
10 ms |
48708 KB |
Output is correct |
3 |
Correct |
10 ms |
48732 KB |
Output is correct |
4 |
Correct |
11 ms |
48692 KB |
Output is correct |
5 |
Correct |
11 ms |
48732 KB |
Output is correct |
6 |
Correct |
12 ms |
48692 KB |
Output is correct |
7 |
Correct |
11 ms |
48732 KB |
Output is correct |
8 |
Correct |
11 ms |
48792 KB |
Output is correct |
9 |
Correct |
10 ms |
48732 KB |
Output is correct |
10 |
Correct |
10 ms |
48732 KB |
Output is correct |
11 |
Correct |
10 ms |
48732 KB |
Output is correct |
12 |
Correct |
12 ms |
48732 KB |
Output is correct |
13 |
Correct |
12 ms |
48732 KB |
Output is correct |
14 |
Correct |
13 ms |
48732 KB |
Output is correct |
15 |
Correct |
12 ms |
48732 KB |
Output is correct |
16 |
Correct |
12 ms |
48936 KB |
Output is correct |
17 |
Correct |
12 ms |
48732 KB |
Output is correct |
18 |
Correct |
11 ms |
48944 KB |
Output is correct |
19 |
Correct |
12 ms |
48728 KB |
Output is correct |
20 |
Correct |
14 ms |
48912 KB |
Output is correct |
21 |
Correct |
12 ms |
48728 KB |
Output is correct |
22 |
Correct |
105 ms |
53140 KB |
Output is correct |
23 |
Correct |
105 ms |
53076 KB |
Output is correct |
24 |
Correct |
143 ms |
57648 KB |
Output is correct |
25 |
Correct |
137 ms |
57524 KB |
Output is correct |
26 |
Correct |
121 ms |
58512 KB |
Output is correct |
27 |
Correct |
113 ms |
58820 KB |
Output is correct |
28 |
Correct |
92 ms |
57168 KB |
Output is correct |
29 |
Correct |
107 ms |
57936 KB |
Output is correct |
30 |
Correct |
140 ms |
57444 KB |
Output is correct |
31 |
Correct |
139 ms |
57564 KB |
Output is correct |
32 |
Correct |
128 ms |
58020 KB |
Output is correct |
33 |
Correct |
129 ms |
58280 KB |
Output is correct |
34 |
Correct |
128 ms |
57428 KB |
Output is correct |
35 |
Correct |
128 ms |
57592 KB |
Output is correct |
36 |
Correct |
125 ms |
57940 KB |
Output is correct |
37 |
Correct |
114 ms |
58040 KB |
Output is correct |
38 |
Correct |
119 ms |
58200 KB |
Output is correct |
39 |
Correct |
93 ms |
57948 KB |
Output is correct |
40 |
Correct |
88 ms |
57540 KB |
Output is correct |
41 |
Correct |
102 ms |
57816 KB |
Output is correct |
42 |
Correct |
91 ms |
57484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
48728 KB |
Output is correct |
2 |
Correct |
10 ms |
48708 KB |
Output is correct |
3 |
Correct |
10 ms |
48732 KB |
Output is correct |
4 |
Correct |
11 ms |
48692 KB |
Output is correct |
5 |
Correct |
11 ms |
48732 KB |
Output is correct |
6 |
Correct |
12 ms |
48692 KB |
Output is correct |
7 |
Correct |
11 ms |
48732 KB |
Output is correct |
8 |
Correct |
11 ms |
48792 KB |
Output is correct |
9 |
Correct |
10 ms |
48732 KB |
Output is correct |
10 |
Correct |
10 ms |
48732 KB |
Output is correct |
11 |
Correct |
10 ms |
48732 KB |
Output is correct |
12 |
Correct |
12 ms |
48732 KB |
Output is correct |
13 |
Correct |
12 ms |
48732 KB |
Output is correct |
14 |
Correct |
13 ms |
48732 KB |
Output is correct |
15 |
Correct |
12 ms |
48732 KB |
Output is correct |
16 |
Correct |
12 ms |
48936 KB |
Output is correct |
17 |
Correct |
12 ms |
48732 KB |
Output is correct |
18 |
Correct |
11 ms |
48944 KB |
Output is correct |
19 |
Correct |
12 ms |
48728 KB |
Output is correct |
20 |
Correct |
14 ms |
48912 KB |
Output is correct |
21 |
Correct |
12 ms |
48728 KB |
Output is correct |
22 |
Correct |
191 ms |
62892 KB |
Output is correct |
23 |
Correct |
190 ms |
63140 KB |
Output is correct |
24 |
Correct |
225 ms |
63824 KB |
Output is correct |
25 |
Correct |
370 ms |
65928 KB |
Output is correct |
26 |
Correct |
189 ms |
63068 KB |
Output is correct |
27 |
Correct |
374 ms |
66064 KB |
Output is correct |
28 |
Correct |
380 ms |
66128 KB |
Output is correct |
29 |
Correct |
174 ms |
61600 KB |
Output is correct |
30 |
Correct |
124 ms |
63756 KB |
Output is correct |
31 |
Correct |
137 ms |
64076 KB |
Output is correct |
32 |
Correct |
298 ms |
66940 KB |
Output is correct |
33 |
Correct |
123 ms |
63604 KB |
Output is correct |
34 |
Correct |
10 ms |
48728 KB |
Output is correct |
35 |
Correct |
11 ms |
48792 KB |
Output is correct |
36 |
Correct |
11 ms |
48732 KB |
Output is correct |
37 |
Correct |
10 ms |
48984 KB |
Output is correct |
38 |
Correct |
12 ms |
48984 KB |
Output is correct |
39 |
Correct |
12 ms |
48732 KB |
Output is correct |
40 |
Correct |
12 ms |
48732 KB |
Output is correct |
41 |
Correct |
119 ms |
63772 KB |
Output is correct |
42 |
Correct |
138 ms |
64080 KB |
Output is correct |
43 |
Correct |
298 ms |
66900 KB |
Output is correct |
44 |
Correct |
125 ms |
63864 KB |
Output is correct |
45 |
Correct |
114 ms |
58196 KB |
Output is correct |
46 |
Correct |
114 ms |
58172 KB |
Output is correct |
47 |
Correct |
89 ms |
58148 KB |
Output is correct |
48 |
Correct |
89 ms |
57680 KB |
Output is correct |
49 |
Correct |
91 ms |
58032 KB |
Output is correct |
50 |
Correct |
89 ms |
57684 KB |
Output is correct |
51 |
Correct |
710 ms |
92184 KB |
Output is correct |
52 |
Correct |
726 ms |
92060 KB |
Output is correct |
53 |
Correct |
548 ms |
92460 KB |
Output is correct |
54 |
Correct |
528 ms |
91588 KB |
Output is correct |
55 |
Correct |
530 ms |
90632 KB |
Output is correct |
56 |
Correct |
105 ms |
53140 KB |
Output is correct |
57 |
Correct |
105 ms |
53076 KB |
Output is correct |
58 |
Correct |
143 ms |
57648 KB |
Output is correct |
59 |
Correct |
137 ms |
57524 KB |
Output is correct |
60 |
Correct |
121 ms |
58512 KB |
Output is correct |
61 |
Correct |
113 ms |
58820 KB |
Output is correct |
62 |
Correct |
92 ms |
57168 KB |
Output is correct |
63 |
Correct |
107 ms |
57936 KB |
Output is correct |
64 |
Correct |
140 ms |
57444 KB |
Output is correct |
65 |
Correct |
139 ms |
57564 KB |
Output is correct |
66 |
Correct |
128 ms |
58020 KB |
Output is correct |
67 |
Correct |
129 ms |
58280 KB |
Output is correct |
68 |
Correct |
128 ms |
57428 KB |
Output is correct |
69 |
Correct |
128 ms |
57592 KB |
Output is correct |
70 |
Correct |
125 ms |
57940 KB |
Output is correct |
71 |
Correct |
114 ms |
58040 KB |
Output is correct |
72 |
Correct |
119 ms |
58200 KB |
Output is correct |
73 |
Correct |
93 ms |
57948 KB |
Output is correct |
74 |
Correct |
88 ms |
57540 KB |
Output is correct |
75 |
Correct |
102 ms |
57816 KB |
Output is correct |
76 |
Correct |
91 ms |
57484 KB |
Output is correct |
77 |
Correct |
864 ms |
89936 KB |
Output is correct |
78 |
Correct |
886 ms |
89316 KB |
Output is correct |
79 |
Correct |
670 ms |
94548 KB |
Output is correct |
80 |
Correct |
682 ms |
95760 KB |
Output is correct |
81 |
Correct |
649 ms |
94056 KB |
Output is correct |
82 |
Correct |
642 ms |
93708 KB |
Output is correct |
83 |
Correct |
850 ms |
89684 KB |
Output is correct |
84 |
Correct |
931 ms |
89424 KB |
Output is correct |
85 |
Correct |
787 ms |
90924 KB |
Output is correct |
86 |
Correct |
739 ms |
88916 KB |
Output is correct |
87 |
Correct |
757 ms |
88944 KB |
Output is correct |
88 |
Correct |
678 ms |
94804 KB |
Output is correct |