#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (b); i >= (a); i --)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPD(i, n) for (int i = 👎 - 1; i >= 0; --i)
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
constexpr ll LINF = (1ll << 60);
constexpr int INF = (1ll << 30);
constexpr int Mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*
Phu Trong from Nguyen Tat Thanh High School for gifted student
*/
template <class X, class Y>
bool minimize(X &x, const Y &y){
X eps = 1e-9;
if (x > y + eps) {x = y; return 1;}
return 0;
}
template <class X, class Y>
bool maximize(X &x, const Y &y){
X eps = 1e-9;
if (x + eps < y) {x = y; return 1;}
return 0;
}
#define MAX 500005
int nArr, nCurtain, numQuery;
vector<int> event[MAX];
vector<pair<int, int>> Q[MAX];
int lz[MAX * 4], st[MAX * 4];
void pushDown(int id){
if (!lz[id]) return;
maximize(st[id << 1], lz[id]);
maximize(st[id << 1 | 1], lz[id]);
maximize(lz[id << 1], lz[id]);
maximize(lz[id << 1 | 1], lz[id]);
lz[id] = 0;
}
void upd(int id, int l, int r, int u, int v, int val){
if (u > r || v < l) return;
if (u <= l && v >= r){
maximize(st[id], val);
maximize(lz[id], val);
return;
}
int m = (l + r) >> 1;
pushDown(id);
upd(id << 1, l, m, u, v, val);
upd(id << 1 | 1, m + 1, r, u, v, val);
st[id] = min(st[id << 1], st[id << 1 | 1]);
}
int query(int id, int l, int r, int u, int v){
if (u > r || v < l) return 1e9;
if (u <= l && v >= r) return st[id];
int m = (l + r) >> 1;
pushDown(id);
int ql = query(id << 1, l, m, u, v);
int qr = query(id << 1 | 1, m + 1, r, u, v);
return min(ql, qr);
}
int ans[MAX];
void process(void){
cin >> nArr >> nCurtain >> numQuery;
for (int i = 1; i <= nCurtain; ++i){
int l, r; cin >> l >> r;
event[r].emplace_back(l);
}
for (int i = 1; i <= numQuery; ++i){
int l, r; cin >> l >> r;
Q[r].emplace_back(l, i);
}
for (int r = 1; r <= nArr; ++r){
for (int &l : event[r]){
upd(1, 1, nArr, l, r, l);
}
for (auto&[l, i] : Q[r]){
ans[i] = (query(1, 1, nArr, l, r) >= l);
}
}
for (int i = 1; i <= numQuery; ++i){
cout << (ans[i] ? "YES" : "NO") << "\n";
}
}
signed main(){
#define name "Whisper"
cin.tie(nullptr) -> sync_with_stdio(false);
//freopen(name".inp", "r", stdin);
//freopen(name".out", "w", stdout);
process();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
23900 KB |
Output is correct |
2 |
Correct |
4 ms |
23900 KB |
Output is correct |
3 |
Correct |
4 ms |
24060 KB |
Output is correct |
4 |
Correct |
4 ms |
23900 KB |
Output is correct |
5 |
Correct |
4 ms |
23900 KB |
Output is correct |
6 |
Correct |
4 ms |
24144 KB |
Output is correct |
7 |
Correct |
4 ms |
23900 KB |
Output is correct |
8 |
Correct |
7 ms |
24156 KB |
Output is correct |
9 |
Correct |
4 ms |
23900 KB |
Output is correct |
10 |
Correct |
5 ms |
23900 KB |
Output is correct |
11 |
Correct |
4 ms |
24008 KB |
Output is correct |
12 |
Correct |
4 ms |
24056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
23900 KB |
Output is correct |
2 |
Correct |
4 ms |
23900 KB |
Output is correct |
3 |
Correct |
4 ms |
24060 KB |
Output is correct |
4 |
Correct |
4 ms |
23900 KB |
Output is correct |
5 |
Correct |
4 ms |
23900 KB |
Output is correct |
6 |
Correct |
4 ms |
24144 KB |
Output is correct |
7 |
Correct |
4 ms |
23900 KB |
Output is correct |
8 |
Correct |
7 ms |
24156 KB |
Output is correct |
9 |
Correct |
4 ms |
23900 KB |
Output is correct |
10 |
Correct |
5 ms |
23900 KB |
Output is correct |
11 |
Correct |
4 ms |
24008 KB |
Output is correct |
12 |
Correct |
4 ms |
24056 KB |
Output is correct |
13 |
Correct |
6 ms |
24156 KB |
Output is correct |
14 |
Correct |
6 ms |
24332 KB |
Output is correct |
15 |
Correct |
6 ms |
24156 KB |
Output is correct |
16 |
Correct |
6 ms |
24156 KB |
Output is correct |
17 |
Correct |
5 ms |
24156 KB |
Output is correct |
18 |
Correct |
5 ms |
24156 KB |
Output is correct |
19 |
Correct |
6 ms |
24344 KB |
Output is correct |
20 |
Correct |
5 ms |
24156 KB |
Output is correct |
21 |
Correct |
6 ms |
24128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
23900 KB |
Output is correct |
2 |
Correct |
4 ms |
23900 KB |
Output is correct |
3 |
Correct |
4 ms |
24060 KB |
Output is correct |
4 |
Correct |
4 ms |
23900 KB |
Output is correct |
5 |
Correct |
4 ms |
23900 KB |
Output is correct |
6 |
Correct |
4 ms |
24144 KB |
Output is correct |
7 |
Correct |
4 ms |
23900 KB |
Output is correct |
8 |
Correct |
7 ms |
24156 KB |
Output is correct |
9 |
Correct |
4 ms |
23900 KB |
Output is correct |
10 |
Correct |
5 ms |
23900 KB |
Output is correct |
11 |
Correct |
4 ms |
24008 KB |
Output is correct |
12 |
Correct |
4 ms |
24056 KB |
Output is correct |
13 |
Correct |
6 ms |
24156 KB |
Output is correct |
14 |
Correct |
6 ms |
24332 KB |
Output is correct |
15 |
Correct |
6 ms |
24156 KB |
Output is correct |
16 |
Correct |
6 ms |
24156 KB |
Output is correct |
17 |
Correct |
5 ms |
24156 KB |
Output is correct |
18 |
Correct |
5 ms |
24156 KB |
Output is correct |
19 |
Correct |
6 ms |
24344 KB |
Output is correct |
20 |
Correct |
5 ms |
24156 KB |
Output is correct |
21 |
Correct |
6 ms |
24128 KB |
Output is correct |
22 |
Correct |
201 ms |
45908 KB |
Output is correct |
23 |
Correct |
160 ms |
46676 KB |
Output is correct |
24 |
Correct |
236 ms |
48212 KB |
Output is correct |
25 |
Correct |
346 ms |
56292 KB |
Output is correct |
26 |
Correct |
159 ms |
46164 KB |
Output is correct |
27 |
Correct |
332 ms |
56676 KB |
Output is correct |
28 |
Correct |
325 ms |
56404 KB |
Output is correct |
29 |
Correct |
159 ms |
44436 KB |
Output is correct |
30 |
Correct |
105 ms |
45652 KB |
Output is correct |
31 |
Correct |
120 ms |
46868 KB |
Output is correct |
32 |
Correct |
260 ms |
55892 KB |
Output is correct |
33 |
Correct |
101 ms |
45712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
23900 KB |
Output is correct |
2 |
Correct |
5 ms |
23900 KB |
Output is correct |
3 |
Correct |
5 ms |
23900 KB |
Output is correct |
4 |
Correct |
5 ms |
24056 KB |
Output is correct |
5 |
Correct |
6 ms |
24332 KB |
Output is correct |
6 |
Correct |
6 ms |
24156 KB |
Output is correct |
7 |
Correct |
6 ms |
24116 KB |
Output is correct |
8 |
Correct |
120 ms |
45664 KB |
Output is correct |
9 |
Correct |
125 ms |
46676 KB |
Output is correct |
10 |
Correct |
274 ms |
55896 KB |
Output is correct |
11 |
Correct |
106 ms |
45904 KB |
Output is correct |
12 |
Correct |
96 ms |
37720 KB |
Output is correct |
13 |
Correct |
99 ms |
37716 KB |
Output is correct |
14 |
Correct |
91 ms |
39252 KB |
Output is correct |
15 |
Correct |
70 ms |
37308 KB |
Output is correct |
16 |
Correct |
75 ms |
37520 KB |
Output is correct |
17 |
Correct |
93 ms |
39096 KB |
Output is correct |
18 |
Correct |
662 ms |
82512 KB |
Output is correct |
19 |
Correct |
609 ms |
82640 KB |
Output is correct |
20 |
Correct |
448 ms |
82516 KB |
Output is correct |
21 |
Correct |
516 ms |
81912 KB |
Output is correct |
22 |
Correct |
439 ms |
81156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
23900 KB |
Output is correct |
2 |
Correct |
4 ms |
23900 KB |
Output is correct |
3 |
Correct |
4 ms |
24060 KB |
Output is correct |
4 |
Correct |
4 ms |
23900 KB |
Output is correct |
5 |
Correct |
4 ms |
23900 KB |
Output is correct |
6 |
Correct |
4 ms |
24144 KB |
Output is correct |
7 |
Correct |
4 ms |
23900 KB |
Output is correct |
8 |
Correct |
7 ms |
24156 KB |
Output is correct |
9 |
Correct |
4 ms |
23900 KB |
Output is correct |
10 |
Correct |
5 ms |
23900 KB |
Output is correct |
11 |
Correct |
4 ms |
24008 KB |
Output is correct |
12 |
Correct |
4 ms |
24056 KB |
Output is correct |
13 |
Correct |
6 ms |
24156 KB |
Output is correct |
14 |
Correct |
6 ms |
24332 KB |
Output is correct |
15 |
Correct |
6 ms |
24156 KB |
Output is correct |
16 |
Correct |
6 ms |
24156 KB |
Output is correct |
17 |
Correct |
5 ms |
24156 KB |
Output is correct |
18 |
Correct |
5 ms |
24156 KB |
Output is correct |
19 |
Correct |
6 ms |
24344 KB |
Output is correct |
20 |
Correct |
5 ms |
24156 KB |
Output is correct |
21 |
Correct |
6 ms |
24128 KB |
Output is correct |
22 |
Correct |
92 ms |
32904 KB |
Output is correct |
23 |
Correct |
93 ms |
33036 KB |
Output is correct |
24 |
Correct |
129 ms |
39252 KB |
Output is correct |
25 |
Correct |
118 ms |
37460 KB |
Output is correct |
26 |
Correct |
81 ms |
40020 KB |
Output is correct |
27 |
Correct |
93 ms |
38640 KB |
Output is correct |
28 |
Correct |
70 ms |
37988 KB |
Output is correct |
29 |
Correct |
79 ms |
39256 KB |
Output is correct |
30 |
Correct |
123 ms |
37504 KB |
Output is correct |
31 |
Correct |
131 ms |
37512 KB |
Output is correct |
32 |
Correct |
106 ms |
39628 KB |
Output is correct |
33 |
Correct |
105 ms |
39764 KB |
Output is correct |
34 |
Correct |
101 ms |
38996 KB |
Output is correct |
35 |
Correct |
113 ms |
39252 KB |
Output is correct |
36 |
Correct |
96 ms |
39636 KB |
Output is correct |
37 |
Correct |
99 ms |
37716 KB |
Output is correct |
38 |
Correct |
99 ms |
37680 KB |
Output is correct |
39 |
Correct |
74 ms |
39256 KB |
Output is correct |
40 |
Correct |
71 ms |
37460 KB |
Output is correct |
41 |
Correct |
71 ms |
37716 KB |
Output is correct |
42 |
Correct |
74 ms |
39004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
23900 KB |
Output is correct |
2 |
Correct |
4 ms |
23900 KB |
Output is correct |
3 |
Correct |
4 ms |
24060 KB |
Output is correct |
4 |
Correct |
4 ms |
23900 KB |
Output is correct |
5 |
Correct |
4 ms |
23900 KB |
Output is correct |
6 |
Correct |
4 ms |
24144 KB |
Output is correct |
7 |
Correct |
4 ms |
23900 KB |
Output is correct |
8 |
Correct |
7 ms |
24156 KB |
Output is correct |
9 |
Correct |
4 ms |
23900 KB |
Output is correct |
10 |
Correct |
5 ms |
23900 KB |
Output is correct |
11 |
Correct |
4 ms |
24008 KB |
Output is correct |
12 |
Correct |
4 ms |
24056 KB |
Output is correct |
13 |
Correct |
6 ms |
24156 KB |
Output is correct |
14 |
Correct |
6 ms |
24332 KB |
Output is correct |
15 |
Correct |
6 ms |
24156 KB |
Output is correct |
16 |
Correct |
6 ms |
24156 KB |
Output is correct |
17 |
Correct |
5 ms |
24156 KB |
Output is correct |
18 |
Correct |
5 ms |
24156 KB |
Output is correct |
19 |
Correct |
6 ms |
24344 KB |
Output is correct |
20 |
Correct |
5 ms |
24156 KB |
Output is correct |
21 |
Correct |
6 ms |
24128 KB |
Output is correct |
22 |
Correct |
201 ms |
45908 KB |
Output is correct |
23 |
Correct |
160 ms |
46676 KB |
Output is correct |
24 |
Correct |
236 ms |
48212 KB |
Output is correct |
25 |
Correct |
346 ms |
56292 KB |
Output is correct |
26 |
Correct |
159 ms |
46164 KB |
Output is correct |
27 |
Correct |
332 ms |
56676 KB |
Output is correct |
28 |
Correct |
325 ms |
56404 KB |
Output is correct |
29 |
Correct |
159 ms |
44436 KB |
Output is correct |
30 |
Correct |
105 ms |
45652 KB |
Output is correct |
31 |
Correct |
120 ms |
46868 KB |
Output is correct |
32 |
Correct |
260 ms |
55892 KB |
Output is correct |
33 |
Correct |
101 ms |
45712 KB |
Output is correct |
34 |
Correct |
4 ms |
23900 KB |
Output is correct |
35 |
Correct |
5 ms |
23900 KB |
Output is correct |
36 |
Correct |
5 ms |
23900 KB |
Output is correct |
37 |
Correct |
5 ms |
24056 KB |
Output is correct |
38 |
Correct |
6 ms |
24332 KB |
Output is correct |
39 |
Correct |
6 ms |
24156 KB |
Output is correct |
40 |
Correct |
6 ms |
24116 KB |
Output is correct |
41 |
Correct |
120 ms |
45664 KB |
Output is correct |
42 |
Correct |
125 ms |
46676 KB |
Output is correct |
43 |
Correct |
274 ms |
55896 KB |
Output is correct |
44 |
Correct |
106 ms |
45904 KB |
Output is correct |
45 |
Correct |
96 ms |
37720 KB |
Output is correct |
46 |
Correct |
99 ms |
37716 KB |
Output is correct |
47 |
Correct |
91 ms |
39252 KB |
Output is correct |
48 |
Correct |
70 ms |
37308 KB |
Output is correct |
49 |
Correct |
75 ms |
37520 KB |
Output is correct |
50 |
Correct |
93 ms |
39096 KB |
Output is correct |
51 |
Correct |
662 ms |
82512 KB |
Output is correct |
52 |
Correct |
609 ms |
82640 KB |
Output is correct |
53 |
Correct |
448 ms |
82516 KB |
Output is correct |
54 |
Correct |
516 ms |
81912 KB |
Output is correct |
55 |
Correct |
439 ms |
81156 KB |
Output is correct |
56 |
Correct |
92 ms |
32904 KB |
Output is correct |
57 |
Correct |
93 ms |
33036 KB |
Output is correct |
58 |
Correct |
129 ms |
39252 KB |
Output is correct |
59 |
Correct |
118 ms |
37460 KB |
Output is correct |
60 |
Correct |
81 ms |
40020 KB |
Output is correct |
61 |
Correct |
93 ms |
38640 KB |
Output is correct |
62 |
Correct |
70 ms |
37988 KB |
Output is correct |
63 |
Correct |
79 ms |
39256 KB |
Output is correct |
64 |
Correct |
123 ms |
37504 KB |
Output is correct |
65 |
Correct |
131 ms |
37512 KB |
Output is correct |
66 |
Correct |
106 ms |
39628 KB |
Output is correct |
67 |
Correct |
105 ms |
39764 KB |
Output is correct |
68 |
Correct |
101 ms |
38996 KB |
Output is correct |
69 |
Correct |
113 ms |
39252 KB |
Output is correct |
70 |
Correct |
96 ms |
39636 KB |
Output is correct |
71 |
Correct |
99 ms |
37716 KB |
Output is correct |
72 |
Correct |
99 ms |
37680 KB |
Output is correct |
73 |
Correct |
74 ms |
39256 KB |
Output is correct |
74 |
Correct |
71 ms |
37460 KB |
Output is correct |
75 |
Correct |
71 ms |
37716 KB |
Output is correct |
76 |
Correct |
74 ms |
39004 KB |
Output is correct |
77 |
Correct |
770 ms |
82268 KB |
Output is correct |
78 |
Correct |
820 ms |
82304 KB |
Output is correct |
79 |
Correct |
584 ms |
86100 KB |
Output is correct |
80 |
Correct |
539 ms |
87596 KB |
Output is correct |
81 |
Correct |
544 ms |
85444 KB |
Output is correct |
82 |
Correct |
560 ms |
85076 KB |
Output is correct |
83 |
Correct |
801 ms |
82260 KB |
Output is correct |
84 |
Correct |
905 ms |
82312 KB |
Output is correct |
85 |
Correct |
777 ms |
83272 KB |
Output is correct |
86 |
Correct |
666 ms |
81236 KB |
Output is correct |
87 |
Correct |
640 ms |
80976 KB |
Output is correct |
88 |
Correct |
573 ms |
86624 KB |
Output is correct |