#include <bits/stdc++.h>
#define int long long
#define re(a, b, c, d) for (auto a = b; a <= c; a += d)
#define de(a, b, c, d) for (auto a = b; a >= c; a -= d)
#define ms (a); memset (a, 0, sizeof a);
#define imax INT_MAX
#define imin INT_MIN
#define wh(a) while (a --)
#define PII pair <int, int>
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define lson (x << 1)
#define rson lson + 1
template <typename T> bool chkmin (T& a, T b) {
return (b < a) ? a = b, 1 : 0;
}
template <typename T> bool chkmax (T& a, T b) {
return (b > a) ? a = b, 1 : 0;
}
using namespace std;
const int N = 1e6 + 5;
int T, n, m, q, s[N], e[N], mn[N << 2], tag[N << 2], ans[N];
vector <int> g[N], que[N];
void down (int x) {
chkmax (tag[lson], tag[x]);
chkmax (tag[rson], tag[x]);
chkmax (mn[lson], tag[x]);
chkmax (mn[rson], tag[x]);
tag[x] = 0;
}
void upd (int x, int l, int r, int L, int R, int val) {
if (L <= l && r <= R) {
chkmax (mn[x], val);
chkmax (tag[x], val);
return;
}
down (x);
int mid = l + r >> 1;
if (mid >= L) upd (lson, l, mid, L, R, val);
if (mid + 1 <= R) upd (rson, mid + 1, r, L, R, val);
mn[x] = min (mn[lson], mn[rson]);
}
int qry (int x, int l, int r, int L, int R) {
if (r < L || l > R) return 1e9;
if (L <= l && r <= R) return mn[x];
int mid = l + r >> 1;
down (x);
return min (qry (lson, l, mid, L, R), qry (rson, mid + 1, r, L, R));
}
signed main () {
cout << fixed << setprecision (0);
ios :: sync_with_stdio (0), cin.tie (0), cout.tie (0);
cin >> n >> m >> q;
int x, y;
re (i, 1, m, 1) cin >> x >> y, g[y].pb (x);
re (i, 1, q, 1) cin >> s[i] >> e[i], que[e[i]].pb (i);
re (i, 1, n, 1) {
for (int l : g[i]) upd (1, 1, n, l, i, l);
for (int k : que[i]) if (qry (1, 1, n, s[k], i) >= s[k]) ans[k] = 1;
}
re (i, 1, q, 1) {
if (ans[i]) cout << "YES";
else cout << "NO";
cout << "\n";
}
return 0;
}
Compilation message
curtains.cpp: In function 'void upd(long long int, long long int, long long int, long long int, long long int, long long int)':
curtains.cpp:41:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
41 | int mid = l + r >> 1;
| ~~^~~
curtains.cpp: In function 'long long int qry(long long int, long long int, long long int, long long int, long long int)':
curtains.cpp:49:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
49 | int mid = l + r >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
51804 KB |
Output is correct |
2 |
Correct |
13 ms |
51800 KB |
Output is correct |
3 |
Correct |
12 ms |
51980 KB |
Output is correct |
4 |
Correct |
14 ms |
52060 KB |
Output is correct |
5 |
Correct |
12 ms |
51800 KB |
Output is correct |
6 |
Correct |
12 ms |
51804 KB |
Output is correct |
7 |
Correct |
13 ms |
51980 KB |
Output is correct |
8 |
Correct |
11 ms |
51804 KB |
Output is correct |
9 |
Correct |
12 ms |
51804 KB |
Output is correct |
10 |
Correct |
12 ms |
51984 KB |
Output is correct |
11 |
Correct |
12 ms |
51804 KB |
Output is correct |
12 |
Correct |
12 ms |
51804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
51804 KB |
Output is correct |
2 |
Correct |
13 ms |
51800 KB |
Output is correct |
3 |
Correct |
12 ms |
51980 KB |
Output is correct |
4 |
Correct |
14 ms |
52060 KB |
Output is correct |
5 |
Correct |
12 ms |
51800 KB |
Output is correct |
6 |
Correct |
12 ms |
51804 KB |
Output is correct |
7 |
Correct |
13 ms |
51980 KB |
Output is correct |
8 |
Correct |
11 ms |
51804 KB |
Output is correct |
9 |
Correct |
12 ms |
51804 KB |
Output is correct |
10 |
Correct |
12 ms |
51984 KB |
Output is correct |
11 |
Correct |
12 ms |
51804 KB |
Output is correct |
12 |
Correct |
12 ms |
51804 KB |
Output is correct |
13 |
Correct |
14 ms |
52060 KB |
Output is correct |
14 |
Correct |
14 ms |
52056 KB |
Output is correct |
15 |
Correct |
15 ms |
52060 KB |
Output is correct |
16 |
Correct |
14 ms |
52060 KB |
Output is correct |
17 |
Correct |
14 ms |
52056 KB |
Output is correct |
18 |
Correct |
13 ms |
52060 KB |
Output is correct |
19 |
Correct |
13 ms |
52060 KB |
Output is correct |
20 |
Correct |
14 ms |
52056 KB |
Output is correct |
21 |
Correct |
13 ms |
52164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
51804 KB |
Output is correct |
2 |
Correct |
13 ms |
51800 KB |
Output is correct |
3 |
Correct |
12 ms |
51980 KB |
Output is correct |
4 |
Correct |
14 ms |
52060 KB |
Output is correct |
5 |
Correct |
12 ms |
51800 KB |
Output is correct |
6 |
Correct |
12 ms |
51804 KB |
Output is correct |
7 |
Correct |
13 ms |
51980 KB |
Output is correct |
8 |
Correct |
11 ms |
51804 KB |
Output is correct |
9 |
Correct |
12 ms |
51804 KB |
Output is correct |
10 |
Correct |
12 ms |
51984 KB |
Output is correct |
11 |
Correct |
12 ms |
51804 KB |
Output is correct |
12 |
Correct |
12 ms |
51804 KB |
Output is correct |
13 |
Correct |
14 ms |
52060 KB |
Output is correct |
14 |
Correct |
14 ms |
52056 KB |
Output is correct |
15 |
Correct |
15 ms |
52060 KB |
Output is correct |
16 |
Correct |
14 ms |
52060 KB |
Output is correct |
17 |
Correct |
14 ms |
52056 KB |
Output is correct |
18 |
Correct |
13 ms |
52060 KB |
Output is correct |
19 |
Correct |
13 ms |
52060 KB |
Output is correct |
20 |
Correct |
14 ms |
52056 KB |
Output is correct |
21 |
Correct |
13 ms |
52164 KB |
Output is correct |
22 |
Correct |
219 ms |
76060 KB |
Output is correct |
23 |
Correct |
218 ms |
76692 KB |
Output is correct |
24 |
Correct |
244 ms |
78432 KB |
Output is correct |
25 |
Correct |
407 ms |
85264 KB |
Output is correct |
26 |
Correct |
205 ms |
75952 KB |
Output is correct |
27 |
Correct |
389 ms |
85196 KB |
Output is correct |
28 |
Correct |
458 ms |
85288 KB |
Output is correct |
29 |
Correct |
181 ms |
75348 KB |
Output is correct |
30 |
Correct |
130 ms |
75404 KB |
Output is correct |
31 |
Correct |
151 ms |
76372 KB |
Output is correct |
32 |
Correct |
408 ms |
84468 KB |
Output is correct |
33 |
Correct |
131 ms |
75572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
51800 KB |
Output is correct |
2 |
Correct |
12 ms |
51804 KB |
Output is correct |
3 |
Correct |
13 ms |
51804 KB |
Output is correct |
4 |
Correct |
12 ms |
51940 KB |
Output is correct |
5 |
Correct |
15 ms |
52060 KB |
Output is correct |
6 |
Correct |
14 ms |
52060 KB |
Output is correct |
7 |
Correct |
13 ms |
52056 KB |
Output is correct |
8 |
Correct |
143 ms |
75432 KB |
Output is correct |
9 |
Correct |
177 ms |
76564 KB |
Output is correct |
10 |
Correct |
335 ms |
84508 KB |
Output is correct |
11 |
Correct |
129 ms |
75600 KB |
Output is correct |
12 |
Correct |
124 ms |
67360 KB |
Output is correct |
13 |
Correct |
141 ms |
67356 KB |
Output is correct |
14 |
Correct |
124 ms |
65364 KB |
Output is correct |
15 |
Correct |
98 ms |
67076 KB |
Output is correct |
16 |
Correct |
106 ms |
65616 KB |
Output is correct |
17 |
Correct |
97 ms |
65124 KB |
Output is correct |
18 |
Correct |
855 ms |
117340 KB |
Output is correct |
19 |
Correct |
858 ms |
117052 KB |
Output is correct |
20 |
Correct |
581 ms |
117332 KB |
Output is correct |
21 |
Correct |
622 ms |
112808 KB |
Output is correct |
22 |
Correct |
567 ms |
114140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
51804 KB |
Output is correct |
2 |
Correct |
13 ms |
51800 KB |
Output is correct |
3 |
Correct |
12 ms |
51980 KB |
Output is correct |
4 |
Correct |
14 ms |
52060 KB |
Output is correct |
5 |
Correct |
12 ms |
51800 KB |
Output is correct |
6 |
Correct |
12 ms |
51804 KB |
Output is correct |
7 |
Correct |
13 ms |
51980 KB |
Output is correct |
8 |
Correct |
11 ms |
51804 KB |
Output is correct |
9 |
Correct |
12 ms |
51804 KB |
Output is correct |
10 |
Correct |
12 ms |
51984 KB |
Output is correct |
11 |
Correct |
12 ms |
51804 KB |
Output is correct |
12 |
Correct |
12 ms |
51804 KB |
Output is correct |
13 |
Correct |
14 ms |
52060 KB |
Output is correct |
14 |
Correct |
14 ms |
52056 KB |
Output is correct |
15 |
Correct |
15 ms |
52060 KB |
Output is correct |
16 |
Correct |
14 ms |
52060 KB |
Output is correct |
17 |
Correct |
14 ms |
52056 KB |
Output is correct |
18 |
Correct |
13 ms |
52060 KB |
Output is correct |
19 |
Correct |
13 ms |
52060 KB |
Output is correct |
20 |
Correct |
14 ms |
52056 KB |
Output is correct |
21 |
Correct |
13 ms |
52164 KB |
Output is correct |
22 |
Correct |
144 ms |
61428 KB |
Output is correct |
23 |
Correct |
113 ms |
61444 KB |
Output is correct |
24 |
Correct |
163 ms |
66740 KB |
Output is correct |
25 |
Correct |
181 ms |
66512 KB |
Output is correct |
26 |
Correct |
116 ms |
67604 KB |
Output is correct |
27 |
Correct |
122 ms |
67408 KB |
Output is correct |
28 |
Correct |
123 ms |
65616 KB |
Output is correct |
29 |
Correct |
108 ms |
67152 KB |
Output is correct |
30 |
Correct |
165 ms |
66644 KB |
Output is correct |
31 |
Correct |
158 ms |
66552 KB |
Output is correct |
32 |
Correct |
136 ms |
67104 KB |
Output is correct |
33 |
Correct |
126 ms |
67156 KB |
Output is correct |
34 |
Correct |
142 ms |
65876 KB |
Output is correct |
35 |
Correct |
152 ms |
66524 KB |
Output is correct |
36 |
Correct |
131 ms |
66896 KB |
Output is correct |
37 |
Correct |
125 ms |
67344 KB |
Output is correct |
38 |
Correct |
130 ms |
67668 KB |
Output is correct |
39 |
Correct |
97 ms |
65360 KB |
Output is correct |
40 |
Correct |
98 ms |
67284 KB |
Output is correct |
41 |
Correct |
96 ms |
65484 KB |
Output is correct |
42 |
Correct |
125 ms |
65224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
51804 KB |
Output is correct |
2 |
Correct |
13 ms |
51800 KB |
Output is correct |
3 |
Correct |
12 ms |
51980 KB |
Output is correct |
4 |
Correct |
14 ms |
52060 KB |
Output is correct |
5 |
Correct |
12 ms |
51800 KB |
Output is correct |
6 |
Correct |
12 ms |
51804 KB |
Output is correct |
7 |
Correct |
13 ms |
51980 KB |
Output is correct |
8 |
Correct |
11 ms |
51804 KB |
Output is correct |
9 |
Correct |
12 ms |
51804 KB |
Output is correct |
10 |
Correct |
12 ms |
51984 KB |
Output is correct |
11 |
Correct |
12 ms |
51804 KB |
Output is correct |
12 |
Correct |
12 ms |
51804 KB |
Output is correct |
13 |
Correct |
14 ms |
52060 KB |
Output is correct |
14 |
Correct |
14 ms |
52056 KB |
Output is correct |
15 |
Correct |
15 ms |
52060 KB |
Output is correct |
16 |
Correct |
14 ms |
52060 KB |
Output is correct |
17 |
Correct |
14 ms |
52056 KB |
Output is correct |
18 |
Correct |
13 ms |
52060 KB |
Output is correct |
19 |
Correct |
13 ms |
52060 KB |
Output is correct |
20 |
Correct |
14 ms |
52056 KB |
Output is correct |
21 |
Correct |
13 ms |
52164 KB |
Output is correct |
22 |
Correct |
219 ms |
76060 KB |
Output is correct |
23 |
Correct |
218 ms |
76692 KB |
Output is correct |
24 |
Correct |
244 ms |
78432 KB |
Output is correct |
25 |
Correct |
407 ms |
85264 KB |
Output is correct |
26 |
Correct |
205 ms |
75952 KB |
Output is correct |
27 |
Correct |
389 ms |
85196 KB |
Output is correct |
28 |
Correct |
458 ms |
85288 KB |
Output is correct |
29 |
Correct |
181 ms |
75348 KB |
Output is correct |
30 |
Correct |
130 ms |
75404 KB |
Output is correct |
31 |
Correct |
151 ms |
76372 KB |
Output is correct |
32 |
Correct |
408 ms |
84468 KB |
Output is correct |
33 |
Correct |
131 ms |
75572 KB |
Output is correct |
34 |
Correct |
11 ms |
51800 KB |
Output is correct |
35 |
Correct |
12 ms |
51804 KB |
Output is correct |
36 |
Correct |
13 ms |
51804 KB |
Output is correct |
37 |
Correct |
12 ms |
51940 KB |
Output is correct |
38 |
Correct |
15 ms |
52060 KB |
Output is correct |
39 |
Correct |
14 ms |
52060 KB |
Output is correct |
40 |
Correct |
13 ms |
52056 KB |
Output is correct |
41 |
Correct |
143 ms |
75432 KB |
Output is correct |
42 |
Correct |
177 ms |
76564 KB |
Output is correct |
43 |
Correct |
335 ms |
84508 KB |
Output is correct |
44 |
Correct |
129 ms |
75600 KB |
Output is correct |
45 |
Correct |
124 ms |
67360 KB |
Output is correct |
46 |
Correct |
141 ms |
67356 KB |
Output is correct |
47 |
Correct |
124 ms |
65364 KB |
Output is correct |
48 |
Correct |
98 ms |
67076 KB |
Output is correct |
49 |
Correct |
106 ms |
65616 KB |
Output is correct |
50 |
Correct |
97 ms |
65124 KB |
Output is correct |
51 |
Correct |
855 ms |
117340 KB |
Output is correct |
52 |
Correct |
858 ms |
117052 KB |
Output is correct |
53 |
Correct |
581 ms |
117332 KB |
Output is correct |
54 |
Correct |
622 ms |
112808 KB |
Output is correct |
55 |
Correct |
567 ms |
114140 KB |
Output is correct |
56 |
Correct |
144 ms |
61428 KB |
Output is correct |
57 |
Correct |
113 ms |
61444 KB |
Output is correct |
58 |
Correct |
163 ms |
66740 KB |
Output is correct |
59 |
Correct |
181 ms |
66512 KB |
Output is correct |
60 |
Correct |
116 ms |
67604 KB |
Output is correct |
61 |
Correct |
122 ms |
67408 KB |
Output is correct |
62 |
Correct |
123 ms |
65616 KB |
Output is correct |
63 |
Correct |
108 ms |
67152 KB |
Output is correct |
64 |
Correct |
165 ms |
66644 KB |
Output is correct |
65 |
Correct |
158 ms |
66552 KB |
Output is correct |
66 |
Correct |
136 ms |
67104 KB |
Output is correct |
67 |
Correct |
126 ms |
67156 KB |
Output is correct |
68 |
Correct |
142 ms |
65876 KB |
Output is correct |
69 |
Correct |
152 ms |
66524 KB |
Output is correct |
70 |
Correct |
131 ms |
66896 KB |
Output is correct |
71 |
Correct |
125 ms |
67344 KB |
Output is correct |
72 |
Correct |
130 ms |
67668 KB |
Output is correct |
73 |
Correct |
97 ms |
65360 KB |
Output is correct |
74 |
Correct |
98 ms |
67284 KB |
Output is correct |
75 |
Correct |
96 ms |
65484 KB |
Output is correct |
76 |
Correct |
125 ms |
65224 KB |
Output is correct |
77 |
Correct |
1118 ms |
112980 KB |
Output is correct |
78 |
Correct |
1031 ms |
112788 KB |
Output is correct |
79 |
Correct |
767 ms |
118652 KB |
Output is correct |
80 |
Correct |
820 ms |
118708 KB |
Output is correct |
81 |
Correct |
838 ms |
116224 KB |
Output is correct |
82 |
Correct |
738 ms |
117584 KB |
Output is correct |
83 |
Correct |
1122 ms |
112676 KB |
Output is correct |
84 |
Correct |
1120 ms |
112792 KB |
Output is correct |
85 |
Correct |
994 ms |
114096 KB |
Output is correct |
86 |
Correct |
909 ms |
111224 KB |
Output is correct |
87 |
Correct |
939 ms |
111700 KB |
Output is correct |
88 |
Correct |
802 ms |
116868 KB |
Output is correct |