#include <bits/stdc++.h>
#define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
#define ll long long
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, a, b) for (int i = (a); i >= (b); --i)
#define pi pair<int,int>
#define ple tuple<int,int,int>
#define fi first
#define se second
#define ii make_pair
#define isz(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
using namespace std;
const int N = 1e6 + 10;
void maximize (int &a, int b) {
a = max(a, b);
}
int n, m, q, res[N];
pi a[N];
vector<pi> ques[N];
vector<int> events[N];
struct STree {
int node[N * 4], lazy[N * 4];
void down (int id, int l, int r) {
if (lazy[id] == 0) return;
maximize(node[id], lazy[id]);
if (l != r) {
maximize(lazy[id*2], lazy[id]);
maximize(lazy[id*2+1], lazy[id]);
}
lazy[id] = 0;
}
void update (int id, int l, int r, int u, int v, int val) {
down(id, l, r);
if (l > v || r < u) return;
if (l >= u && r <= v) {
lazy[id] = val;
down(id, l, r);
return;
}
int mid = l + r >> 1;
update(id*2, l, mid, u, v, val);
update(id*2+1, mid+1, r, u, v, val);
node[id] = min(node[id*2], node[id*2+1]);
}
int get (int id, int l, int r, int u, int v) {
down(id, l, r);
if (l > v || r < u) return 1e9;
if (l >= u && r <= v) return node[id];
int mid = l + r >> 1;
return min(get(id*2,l,mid,u,v),get(id*2+1,mid+1,r,u,v));
}
} st;
int main () {
file("pupil");
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m >> q;
FOR(i,1,m) {
int l,r; cin >> l >> r;
events[r].push_back(l);
}
FOR(i,1,q) {
int l,r; cin >> l >> r;
ques[r].push_back({l, i});
}
FOR(r,1,n) {
for (int l : events[r]) {
st.update(1, 1, n, l, r, l);
}
for (pi it : ques[r]) {
int l = it.fi;
int id = it.se;
if (st.get(1,1,n,l,r) >= l) {
res[id] = true;
}
}
}
FOR(i,1,q) {
cout << (res[i] == true ? "YES\n" : "NO\n");
}
}
Compilation message
curtains.cpp: In member function 'void STree::update(int, int, int, int, int, int)':
curtains.cpp:46:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
46 | int mid = l + r >> 1;
| ~~^~~
curtains.cpp: In member function 'int STree::get(int, int, int, int, int)':
curtains.cpp:55:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
55 | int mid = l + r >> 1;
| ~~^~~
curtains.cpp: In function 'int main()':
curtains.cpp:2:60: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
2 | #define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:61:7: note: in expansion of macro 'file'
61 | file("pupil");
| ^~~~
curtains.cpp:2:94: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
2 | #define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:61:7: note: in expansion of macro 'file'
61 | file("pupil");
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
51544 KB |
Output is correct |
2 |
Correct |
11 ms |
51776 KB |
Output is correct |
3 |
Correct |
12 ms |
51548 KB |
Output is correct |
4 |
Correct |
11 ms |
51548 KB |
Output is correct |
5 |
Correct |
11 ms |
51736 KB |
Output is correct |
6 |
Correct |
11 ms |
51548 KB |
Output is correct |
7 |
Correct |
10 ms |
51788 KB |
Output is correct |
8 |
Correct |
10 ms |
49496 KB |
Output is correct |
9 |
Correct |
10 ms |
51672 KB |
Output is correct |
10 |
Correct |
10 ms |
49664 KB |
Output is correct |
11 |
Correct |
11 ms |
51548 KB |
Output is correct |
12 |
Correct |
12 ms |
51548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
51544 KB |
Output is correct |
2 |
Correct |
11 ms |
51776 KB |
Output is correct |
3 |
Correct |
12 ms |
51548 KB |
Output is correct |
4 |
Correct |
11 ms |
51548 KB |
Output is correct |
5 |
Correct |
11 ms |
51736 KB |
Output is correct |
6 |
Correct |
11 ms |
51548 KB |
Output is correct |
7 |
Correct |
10 ms |
51788 KB |
Output is correct |
8 |
Correct |
10 ms |
49496 KB |
Output is correct |
9 |
Correct |
10 ms |
51672 KB |
Output is correct |
10 |
Correct |
10 ms |
49664 KB |
Output is correct |
11 |
Correct |
11 ms |
51548 KB |
Output is correct |
12 |
Correct |
12 ms |
51548 KB |
Output is correct |
13 |
Correct |
13 ms |
51804 KB |
Output is correct |
14 |
Correct |
12 ms |
51828 KB |
Output is correct |
15 |
Correct |
12 ms |
51804 KB |
Output is correct |
16 |
Correct |
12 ms |
51816 KB |
Output is correct |
17 |
Correct |
12 ms |
51800 KB |
Output is correct |
18 |
Correct |
11 ms |
51800 KB |
Output is correct |
19 |
Correct |
11 ms |
49756 KB |
Output is correct |
20 |
Correct |
12 ms |
51900 KB |
Output is correct |
21 |
Correct |
12 ms |
51804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
51544 KB |
Output is correct |
2 |
Correct |
11 ms |
51776 KB |
Output is correct |
3 |
Correct |
12 ms |
51548 KB |
Output is correct |
4 |
Correct |
11 ms |
51548 KB |
Output is correct |
5 |
Correct |
11 ms |
51736 KB |
Output is correct |
6 |
Correct |
11 ms |
51548 KB |
Output is correct |
7 |
Correct |
10 ms |
51788 KB |
Output is correct |
8 |
Correct |
10 ms |
49496 KB |
Output is correct |
9 |
Correct |
10 ms |
51672 KB |
Output is correct |
10 |
Correct |
10 ms |
49664 KB |
Output is correct |
11 |
Correct |
11 ms |
51548 KB |
Output is correct |
12 |
Correct |
12 ms |
51548 KB |
Output is correct |
13 |
Correct |
13 ms |
51804 KB |
Output is correct |
14 |
Correct |
12 ms |
51828 KB |
Output is correct |
15 |
Correct |
12 ms |
51804 KB |
Output is correct |
16 |
Correct |
12 ms |
51816 KB |
Output is correct |
17 |
Correct |
12 ms |
51800 KB |
Output is correct |
18 |
Correct |
11 ms |
51800 KB |
Output is correct |
19 |
Correct |
11 ms |
49756 KB |
Output is correct |
20 |
Correct |
12 ms |
51900 KB |
Output is correct |
21 |
Correct |
12 ms |
51804 KB |
Output is correct |
22 |
Correct |
159 ms |
66012 KB |
Output is correct |
23 |
Correct |
153 ms |
66328 KB |
Output is correct |
24 |
Correct |
177 ms |
67812 KB |
Output is correct |
25 |
Correct |
297 ms |
73380 KB |
Output is correct |
26 |
Correct |
151 ms |
66232 KB |
Output is correct |
27 |
Correct |
303 ms |
73552 KB |
Output is correct |
28 |
Correct |
355 ms |
73812 KB |
Output is correct |
29 |
Correct |
132 ms |
65108 KB |
Output is correct |
30 |
Correct |
95 ms |
65168 KB |
Output is correct |
31 |
Correct |
117 ms |
66128 KB |
Output is correct |
32 |
Correct |
243 ms |
72528 KB |
Output is correct |
33 |
Correct |
118 ms |
65396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
51544 KB |
Output is correct |
2 |
Correct |
11 ms |
49500 KB |
Output is correct |
3 |
Correct |
10 ms |
51544 KB |
Output is correct |
4 |
Correct |
11 ms |
49752 KB |
Output is correct |
5 |
Correct |
12 ms |
51892 KB |
Output is correct |
6 |
Correct |
13 ms |
51804 KB |
Output is correct |
7 |
Correct |
12 ms |
50008 KB |
Output is correct |
8 |
Correct |
98 ms |
65236 KB |
Output is correct |
9 |
Correct |
112 ms |
65872 KB |
Output is correct |
10 |
Correct |
243 ms |
72528 KB |
Output is correct |
11 |
Correct |
94 ms |
65172 KB |
Output is correct |
12 |
Correct |
102 ms |
62984 KB |
Output is correct |
13 |
Correct |
96 ms |
62804 KB |
Output is correct |
14 |
Correct |
84 ms |
58780 KB |
Output is correct |
15 |
Correct |
91 ms |
62640 KB |
Output is correct |
16 |
Correct |
75 ms |
58960 KB |
Output is correct |
17 |
Correct |
77 ms |
60500 KB |
Output is correct |
18 |
Correct |
590 ms |
99480 KB |
Output is correct |
19 |
Correct |
627 ms |
99628 KB |
Output is correct |
20 |
Correct |
480 ms |
99664 KB |
Output is correct |
21 |
Correct |
485 ms |
94584 KB |
Output is correct |
22 |
Correct |
487 ms |
96064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
51544 KB |
Output is correct |
2 |
Correct |
11 ms |
51776 KB |
Output is correct |
3 |
Correct |
12 ms |
51548 KB |
Output is correct |
4 |
Correct |
11 ms |
51548 KB |
Output is correct |
5 |
Correct |
11 ms |
51736 KB |
Output is correct |
6 |
Correct |
11 ms |
51548 KB |
Output is correct |
7 |
Correct |
10 ms |
51788 KB |
Output is correct |
8 |
Correct |
10 ms |
49496 KB |
Output is correct |
9 |
Correct |
10 ms |
51672 KB |
Output is correct |
10 |
Correct |
10 ms |
49664 KB |
Output is correct |
11 |
Correct |
11 ms |
51548 KB |
Output is correct |
12 |
Correct |
12 ms |
51548 KB |
Output is correct |
13 |
Correct |
13 ms |
51804 KB |
Output is correct |
14 |
Correct |
12 ms |
51828 KB |
Output is correct |
15 |
Correct |
12 ms |
51804 KB |
Output is correct |
16 |
Correct |
12 ms |
51816 KB |
Output is correct |
17 |
Correct |
12 ms |
51800 KB |
Output is correct |
18 |
Correct |
11 ms |
51800 KB |
Output is correct |
19 |
Correct |
11 ms |
49756 KB |
Output is correct |
20 |
Correct |
12 ms |
51900 KB |
Output is correct |
21 |
Correct |
12 ms |
51804 KB |
Output is correct |
22 |
Correct |
87 ms |
58448 KB |
Output is correct |
23 |
Correct |
96 ms |
58396 KB |
Output is correct |
24 |
Correct |
118 ms |
62032 KB |
Output is correct |
25 |
Correct |
118 ms |
62224 KB |
Output is correct |
26 |
Correct |
90 ms |
63124 KB |
Output is correct |
27 |
Correct |
110 ms |
63328 KB |
Output is correct |
28 |
Correct |
76 ms |
61264 KB |
Output is correct |
29 |
Correct |
87 ms |
62676 KB |
Output is correct |
30 |
Correct |
139 ms |
62072 KB |
Output is correct |
31 |
Correct |
119 ms |
62036 KB |
Output is correct |
32 |
Correct |
105 ms |
62548 KB |
Output is correct |
33 |
Correct |
100 ms |
62880 KB |
Output is correct |
34 |
Correct |
107 ms |
61700 KB |
Output is correct |
35 |
Correct |
106 ms |
62072 KB |
Output is correct |
36 |
Correct |
126 ms |
62544 KB |
Output is correct |
37 |
Correct |
96 ms |
63064 KB |
Output is correct |
38 |
Correct |
100 ms |
62960 KB |
Output is correct |
39 |
Correct |
82 ms |
58904 KB |
Output is correct |
40 |
Correct |
83 ms |
62544 KB |
Output is correct |
41 |
Correct |
76 ms |
58964 KB |
Output is correct |
42 |
Correct |
77 ms |
60492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
51544 KB |
Output is correct |
2 |
Correct |
11 ms |
51776 KB |
Output is correct |
3 |
Correct |
12 ms |
51548 KB |
Output is correct |
4 |
Correct |
11 ms |
51548 KB |
Output is correct |
5 |
Correct |
11 ms |
51736 KB |
Output is correct |
6 |
Correct |
11 ms |
51548 KB |
Output is correct |
7 |
Correct |
10 ms |
51788 KB |
Output is correct |
8 |
Correct |
10 ms |
49496 KB |
Output is correct |
9 |
Correct |
10 ms |
51672 KB |
Output is correct |
10 |
Correct |
10 ms |
49664 KB |
Output is correct |
11 |
Correct |
11 ms |
51548 KB |
Output is correct |
12 |
Correct |
12 ms |
51548 KB |
Output is correct |
13 |
Correct |
13 ms |
51804 KB |
Output is correct |
14 |
Correct |
12 ms |
51828 KB |
Output is correct |
15 |
Correct |
12 ms |
51804 KB |
Output is correct |
16 |
Correct |
12 ms |
51816 KB |
Output is correct |
17 |
Correct |
12 ms |
51800 KB |
Output is correct |
18 |
Correct |
11 ms |
51800 KB |
Output is correct |
19 |
Correct |
11 ms |
49756 KB |
Output is correct |
20 |
Correct |
12 ms |
51900 KB |
Output is correct |
21 |
Correct |
12 ms |
51804 KB |
Output is correct |
22 |
Correct |
159 ms |
66012 KB |
Output is correct |
23 |
Correct |
153 ms |
66328 KB |
Output is correct |
24 |
Correct |
177 ms |
67812 KB |
Output is correct |
25 |
Correct |
297 ms |
73380 KB |
Output is correct |
26 |
Correct |
151 ms |
66232 KB |
Output is correct |
27 |
Correct |
303 ms |
73552 KB |
Output is correct |
28 |
Correct |
355 ms |
73812 KB |
Output is correct |
29 |
Correct |
132 ms |
65108 KB |
Output is correct |
30 |
Correct |
95 ms |
65168 KB |
Output is correct |
31 |
Correct |
117 ms |
66128 KB |
Output is correct |
32 |
Correct |
243 ms |
72528 KB |
Output is correct |
33 |
Correct |
118 ms |
65396 KB |
Output is correct |
34 |
Correct |
11 ms |
51544 KB |
Output is correct |
35 |
Correct |
11 ms |
49500 KB |
Output is correct |
36 |
Correct |
10 ms |
51544 KB |
Output is correct |
37 |
Correct |
11 ms |
49752 KB |
Output is correct |
38 |
Correct |
12 ms |
51892 KB |
Output is correct |
39 |
Correct |
13 ms |
51804 KB |
Output is correct |
40 |
Correct |
12 ms |
50008 KB |
Output is correct |
41 |
Correct |
98 ms |
65236 KB |
Output is correct |
42 |
Correct |
112 ms |
65872 KB |
Output is correct |
43 |
Correct |
243 ms |
72528 KB |
Output is correct |
44 |
Correct |
94 ms |
65172 KB |
Output is correct |
45 |
Correct |
102 ms |
62984 KB |
Output is correct |
46 |
Correct |
96 ms |
62804 KB |
Output is correct |
47 |
Correct |
84 ms |
58780 KB |
Output is correct |
48 |
Correct |
91 ms |
62640 KB |
Output is correct |
49 |
Correct |
75 ms |
58960 KB |
Output is correct |
50 |
Correct |
77 ms |
60500 KB |
Output is correct |
51 |
Correct |
590 ms |
99480 KB |
Output is correct |
52 |
Correct |
627 ms |
99628 KB |
Output is correct |
53 |
Correct |
480 ms |
99664 KB |
Output is correct |
54 |
Correct |
485 ms |
94584 KB |
Output is correct |
55 |
Correct |
487 ms |
96064 KB |
Output is correct |
56 |
Correct |
87 ms |
58448 KB |
Output is correct |
57 |
Correct |
96 ms |
58396 KB |
Output is correct |
58 |
Correct |
118 ms |
62032 KB |
Output is correct |
59 |
Correct |
118 ms |
62224 KB |
Output is correct |
60 |
Correct |
90 ms |
63124 KB |
Output is correct |
61 |
Correct |
110 ms |
63328 KB |
Output is correct |
62 |
Correct |
76 ms |
61264 KB |
Output is correct |
63 |
Correct |
87 ms |
62676 KB |
Output is correct |
64 |
Correct |
139 ms |
62072 KB |
Output is correct |
65 |
Correct |
119 ms |
62036 KB |
Output is correct |
66 |
Correct |
105 ms |
62548 KB |
Output is correct |
67 |
Correct |
100 ms |
62880 KB |
Output is correct |
68 |
Correct |
107 ms |
61700 KB |
Output is correct |
69 |
Correct |
106 ms |
62072 KB |
Output is correct |
70 |
Correct |
126 ms |
62544 KB |
Output is correct |
71 |
Correct |
96 ms |
63064 KB |
Output is correct |
72 |
Correct |
100 ms |
62960 KB |
Output is correct |
73 |
Correct |
82 ms |
58904 KB |
Output is correct |
74 |
Correct |
83 ms |
62544 KB |
Output is correct |
75 |
Correct |
76 ms |
58964 KB |
Output is correct |
76 |
Correct |
77 ms |
60492 KB |
Output is correct |
77 |
Correct |
701 ms |
95880 KB |
Output is correct |
78 |
Correct |
765 ms |
95764 KB |
Output is correct |
79 |
Correct |
544 ms |
101508 KB |
Output is correct |
80 |
Correct |
577 ms |
102224 KB |
Output is correct |
81 |
Correct |
546 ms |
99968 KB |
Output is correct |
82 |
Correct |
554 ms |
100404 KB |
Output is correct |
83 |
Correct |
712 ms |
95752 KB |
Output is correct |
84 |
Correct |
704 ms |
95628 KB |
Output is correct |
85 |
Correct |
669 ms |
97416 KB |
Output is correct |
86 |
Correct |
625 ms |
93776 KB |
Output is correct |
87 |
Correct |
601 ms |
93520 KB |
Output is correct |
88 |
Correct |
570 ms |
100180 KB |
Output is correct |