#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 5e5+10;
const int INF = INT_MAX;
const int mod = 1e9+7;
const string NAME = "solve";
int n,m,t;
pair<int,int> edges[N];
vector<pair<int,int>> events[N];
int ans[N];
int tree[4*N],lazy[4*N];
void down(int id, int l, int r) {
int &t = lazy[id];
if(t == 0) {
return;
}
tree[id] = max(tree[id],t);
if(l < r) {
lazy[id << 1] = max(lazy[id << 1],t);
lazy[id << 1 | 1] = max(lazy[id << 1 | 1],t);
}
t = 0;
}
void update(int u, int v, int val, int id = 1, int l = 1, int r = n) {
down(id,l,r);
if(r < u or v < l) {
return;
}
if(u <= l and r <= v) {
lazy[id] = val;
down(id,l,r);
return;
}
int mid = l + r >> 1;
update(u,v,val,id << 1,l,mid);
update(u,v,val,id << 1 | 1,mid+1,r);
tree[id] = min(tree[id << 1],tree[id << 1 | 1]);
}
int get(int u, int v, int id = 1, int l = 1, int r = n) {
down(id,l,r);
if(r < u or v < l) {
return mod;
}
if(u <= l and r <= v) {
return tree[id];
}
int mid = l + r >> 1;
return min(get(u,v,id << 1,l,mid),get(u,v,id << 1 | 1,mid+1,r));
}
signed main()
{
if (fopen((NAME + ".inp").c_str(), "r")) {
freopen((NAME + ".inp").c_str(), "r", stdin);
freopen((NAME + ".out").c_str(), "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> t;
for(int i = 1 ; i <= m ; i++) {
int l,r; cin >> l >> r;
edges[i] = {r,l};
}
for(int i = 1 ; i <= t ; i++) {
int l,r; cin >> l >> r;
events[r].push_back({l,i});
}
sort(edges+1,edges+m+1);
for(int i = 1, j = 1 ; i <= n ; i++) {
while(j <= n and edges[j].first <= i) {
update(edges[j].second,edges[j].first,edges[j].second);
j++;
}
for(auto p:events[i]) {
int val = get(p.first,i);
if(val >= p.first) {
ans[p.second] = 1;
}
}
}
for(int i = 1 ; i <= t ; i++) {
if(ans[i]) {
cout << "YES" << '\n';
}
else {
cout << "NO" << '\n';
}
}
return 0;
}
Compilation message
curtains.cpp: In function 'void update(int, int, int, int, int, int)':
curtains.cpp:41:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
41 | int mid = l + r >> 1;
| ~~^~~
curtains.cpp: In function 'int get(int, int, int, int, int)':
curtains.cpp:55:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
55 | int mid = l + r >> 1;
| ~~^~~
curtains.cpp: In function 'int main()':
curtains.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
62 | freopen((NAME + ".inp").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
63 | freopen((NAME + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
16732 KB |
Output is correct |
2 |
Correct |
3 ms |
16732 KB |
Output is correct |
3 |
Correct |
3 ms |
16732 KB |
Output is correct |
4 |
Correct |
3 ms |
16732 KB |
Output is correct |
5 |
Correct |
3 ms |
16728 KB |
Output is correct |
6 |
Correct |
3 ms |
16732 KB |
Output is correct |
7 |
Correct |
3 ms |
16728 KB |
Output is correct |
8 |
Correct |
3 ms |
14684 KB |
Output is correct |
9 |
Correct |
3 ms |
16732 KB |
Output is correct |
10 |
Correct |
3 ms |
14684 KB |
Output is correct |
11 |
Correct |
3 ms |
16732 KB |
Output is correct |
12 |
Correct |
3 ms |
16732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
16732 KB |
Output is correct |
2 |
Correct |
3 ms |
16732 KB |
Output is correct |
3 |
Correct |
3 ms |
16732 KB |
Output is correct |
4 |
Correct |
3 ms |
16732 KB |
Output is correct |
5 |
Correct |
3 ms |
16728 KB |
Output is correct |
6 |
Correct |
3 ms |
16732 KB |
Output is correct |
7 |
Correct |
3 ms |
16728 KB |
Output is correct |
8 |
Correct |
3 ms |
14684 KB |
Output is correct |
9 |
Correct |
3 ms |
16732 KB |
Output is correct |
10 |
Correct |
3 ms |
14684 KB |
Output is correct |
11 |
Correct |
3 ms |
16732 KB |
Output is correct |
12 |
Correct |
3 ms |
16732 KB |
Output is correct |
13 |
Correct |
5 ms |
16728 KB |
Output is correct |
14 |
Correct |
5 ms |
16732 KB |
Output is correct |
15 |
Correct |
5 ms |
16732 KB |
Output is correct |
16 |
Correct |
5 ms |
16728 KB |
Output is correct |
17 |
Correct |
5 ms |
16988 KB |
Output is correct |
18 |
Correct |
4 ms |
16988 KB |
Output is correct |
19 |
Correct |
4 ms |
14940 KB |
Output is correct |
20 |
Correct |
4 ms |
16728 KB |
Output is correct |
21 |
Correct |
5 ms |
16732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
16732 KB |
Output is correct |
2 |
Correct |
3 ms |
16732 KB |
Output is correct |
3 |
Correct |
3 ms |
16732 KB |
Output is correct |
4 |
Correct |
3 ms |
16732 KB |
Output is correct |
5 |
Correct |
3 ms |
16728 KB |
Output is correct |
6 |
Correct |
3 ms |
16732 KB |
Output is correct |
7 |
Correct |
3 ms |
16728 KB |
Output is correct |
8 |
Correct |
3 ms |
14684 KB |
Output is correct |
9 |
Correct |
3 ms |
16732 KB |
Output is correct |
10 |
Correct |
3 ms |
14684 KB |
Output is correct |
11 |
Correct |
3 ms |
16732 KB |
Output is correct |
12 |
Correct |
3 ms |
16732 KB |
Output is correct |
13 |
Correct |
5 ms |
16728 KB |
Output is correct |
14 |
Correct |
5 ms |
16732 KB |
Output is correct |
15 |
Correct |
5 ms |
16732 KB |
Output is correct |
16 |
Correct |
5 ms |
16728 KB |
Output is correct |
17 |
Correct |
5 ms |
16988 KB |
Output is correct |
18 |
Correct |
4 ms |
16988 KB |
Output is correct |
19 |
Correct |
4 ms |
14940 KB |
Output is correct |
20 |
Correct |
4 ms |
16728 KB |
Output is correct |
21 |
Correct |
5 ms |
16732 KB |
Output is correct |
22 |
Correct |
182 ms |
24668 KB |
Output is correct |
23 |
Incorrect |
180 ms |
24588 KB |
Output isn't correct |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
16744 KB |
Output is correct |
2 |
Correct |
3 ms |
14684 KB |
Output is correct |
3 |
Correct |
3 ms |
16732 KB |
Output is correct |
4 |
Correct |
3 ms |
14884 KB |
Output is correct |
5 |
Correct |
5 ms |
16988 KB |
Output is correct |
6 |
Correct |
4 ms |
16988 KB |
Output is correct |
7 |
Correct |
4 ms |
15192 KB |
Output is correct |
8 |
Incorrect |
120 ms |
24832 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
16732 KB |
Output is correct |
2 |
Correct |
3 ms |
16732 KB |
Output is correct |
3 |
Correct |
3 ms |
16732 KB |
Output is correct |
4 |
Correct |
3 ms |
16732 KB |
Output is correct |
5 |
Correct |
3 ms |
16728 KB |
Output is correct |
6 |
Correct |
3 ms |
16732 KB |
Output is correct |
7 |
Correct |
3 ms |
16728 KB |
Output is correct |
8 |
Correct |
3 ms |
14684 KB |
Output is correct |
9 |
Correct |
3 ms |
16732 KB |
Output is correct |
10 |
Correct |
3 ms |
14684 KB |
Output is correct |
11 |
Correct |
3 ms |
16732 KB |
Output is correct |
12 |
Correct |
3 ms |
16732 KB |
Output is correct |
13 |
Correct |
5 ms |
16728 KB |
Output is correct |
14 |
Correct |
5 ms |
16732 KB |
Output is correct |
15 |
Correct |
5 ms |
16732 KB |
Output is correct |
16 |
Correct |
5 ms |
16728 KB |
Output is correct |
17 |
Correct |
5 ms |
16988 KB |
Output is correct |
18 |
Correct |
4 ms |
16988 KB |
Output is correct |
19 |
Correct |
4 ms |
14940 KB |
Output is correct |
20 |
Correct |
4 ms |
16728 KB |
Output is correct |
21 |
Correct |
5 ms |
16732 KB |
Output is correct |
22 |
Incorrect |
69 ms |
18676 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
16732 KB |
Output is correct |
2 |
Correct |
3 ms |
16732 KB |
Output is correct |
3 |
Correct |
3 ms |
16732 KB |
Output is correct |
4 |
Correct |
3 ms |
16732 KB |
Output is correct |
5 |
Correct |
3 ms |
16728 KB |
Output is correct |
6 |
Correct |
3 ms |
16732 KB |
Output is correct |
7 |
Correct |
3 ms |
16728 KB |
Output is correct |
8 |
Correct |
3 ms |
14684 KB |
Output is correct |
9 |
Correct |
3 ms |
16732 KB |
Output is correct |
10 |
Correct |
3 ms |
14684 KB |
Output is correct |
11 |
Correct |
3 ms |
16732 KB |
Output is correct |
12 |
Correct |
3 ms |
16732 KB |
Output is correct |
13 |
Correct |
5 ms |
16728 KB |
Output is correct |
14 |
Correct |
5 ms |
16732 KB |
Output is correct |
15 |
Correct |
5 ms |
16732 KB |
Output is correct |
16 |
Correct |
5 ms |
16728 KB |
Output is correct |
17 |
Correct |
5 ms |
16988 KB |
Output is correct |
18 |
Correct |
4 ms |
16988 KB |
Output is correct |
19 |
Correct |
4 ms |
14940 KB |
Output is correct |
20 |
Correct |
4 ms |
16728 KB |
Output is correct |
21 |
Correct |
5 ms |
16732 KB |
Output is correct |
22 |
Correct |
182 ms |
24668 KB |
Output is correct |
23 |
Incorrect |
180 ms |
24588 KB |
Output isn't correct |
24 |
Halted |
0 ms |
0 KB |
- |