# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1106167 |
2024-10-29T12:44:56 Z |
ro9669 |
Curtains (NOI23_curtains) |
C++17 |
|
751 ms |
81484 KB |
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) v.begin() , v.end()
#define sz(v) int(v.size())
#define unq(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
using namespace std;
typedef long long ll;
typedef pair<int , int> ii;
typedef pair<long long , int> lli;
const int maxN = int(5e5)+7;
const int inf = int(1e9)+7;
int n , m , q;
vector<int> event[maxN];
vector<ii> query[maxN];
struct node{
int val , lazy;
node(){
val = lazy = inf;
}
} st[4 * maxN];
#define lef(id) id * 2
#define rig(id) id * 2 + 1
void modify(int id , int x){
st[id].val = min(st[id].val , x);
st[id].lazy = min(st[id].lazy , x);
}
void down(int id , int l , int r){
int &x = st[id].lazy;
if (l == r) return;
modify(lef(id) , x);
modify(rig(id) , x);
}
void update(int id , int l , int r , int u , int v , int x){
if (v < l || r < u) return;
if (u <= l && r <= v){
modify(id , x);
//cout << l << " " << r << " " << st[id].val << "\n";
return;
}
down(id , l , r);
int mid = (l + r) / 2;
update(lef(id) , l , mid , u , v , x);
update(rig(id) , mid + 1 , r , u , v , x);
st[id].val = max(st[lef(id)].val , st[rig(id)].val);
}
int get(int id , int l , int r , int u , int v){
if (v < l || r < u) return -inf;
if (u <= l && r <= v) return st[id].val;
down(id , l , r);
int mid = (l + r) / 2;
return max(get(lef(id) , l , mid , u , v) , get(rig(id) , mid + 1 , r , u , v));
}
bool res[maxN];
void solve(){
cin >> n >> m >> q;
for (int i = 1 ; i <= m ; i++){
int l , r;
cin >> l >> r;
event[l].push_back(r);
}
for (int i = 1 ; i <= q ; i++){
int l , r;
cin >> l >> r;
query[l].push_back({r , i});
}
for (int i = n ; i >= 1 ; i--){
for (auto it : event[i]){
update(1 , 1 , n , i , it , it);
}
for (auto it : query[i]){
res[it.se] = (get(1 , 1 , n , i , it.fi) <= it.fi);
}
}
for (int i = 1 ; i <= q ; i++){
if (res[i]) cout << "YES\n"; else cout << "NO\n";
}
}
#define name "A"
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen(name".INP" , "r")){
freopen(name".INP" , "r" , stdin);
freopen(name".OUT" , "w" , stdout);
}
int t = 1; //cin >> t;
while (t--) solve();
return 0;
}
Compilation message
curtains.cpp: In function 'int main()':
curtains.cpp:96:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
96 | freopen(name".INP" , "r" , stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:97:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
97 | freopen(name".OUT" , "w" , stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
39760 KB |
Output is correct |
2 |
Correct |
7 ms |
39760 KB |
Output is correct |
3 |
Correct |
9 ms |
39760 KB |
Output is correct |
4 |
Correct |
8 ms |
39760 KB |
Output is correct |
5 |
Correct |
8 ms |
39760 KB |
Output is correct |
6 |
Correct |
9 ms |
39760 KB |
Output is correct |
7 |
Correct |
8 ms |
39760 KB |
Output is correct |
8 |
Correct |
7 ms |
39760 KB |
Output is correct |
9 |
Correct |
8 ms |
39760 KB |
Output is correct |
10 |
Correct |
8 ms |
39760 KB |
Output is correct |
11 |
Correct |
8 ms |
39760 KB |
Output is correct |
12 |
Correct |
8 ms |
39868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
39760 KB |
Output is correct |
2 |
Correct |
7 ms |
39760 KB |
Output is correct |
3 |
Correct |
9 ms |
39760 KB |
Output is correct |
4 |
Correct |
8 ms |
39760 KB |
Output is correct |
5 |
Correct |
8 ms |
39760 KB |
Output is correct |
6 |
Correct |
9 ms |
39760 KB |
Output is correct |
7 |
Correct |
8 ms |
39760 KB |
Output is correct |
8 |
Correct |
7 ms |
39760 KB |
Output is correct |
9 |
Correct |
8 ms |
39760 KB |
Output is correct |
10 |
Correct |
8 ms |
39760 KB |
Output is correct |
11 |
Correct |
8 ms |
39760 KB |
Output is correct |
12 |
Correct |
8 ms |
39868 KB |
Output is correct |
13 |
Correct |
9 ms |
40016 KB |
Output is correct |
14 |
Correct |
9 ms |
40016 KB |
Output is correct |
15 |
Correct |
9 ms |
40036 KB |
Output is correct |
16 |
Correct |
9 ms |
40016 KB |
Output is correct |
17 |
Correct |
10 ms |
39868 KB |
Output is correct |
18 |
Correct |
9 ms |
40016 KB |
Output is correct |
19 |
Correct |
9 ms |
40040 KB |
Output is correct |
20 |
Correct |
9 ms |
40016 KB |
Output is correct |
21 |
Correct |
9 ms |
40016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
39760 KB |
Output is correct |
2 |
Correct |
7 ms |
39760 KB |
Output is correct |
3 |
Correct |
9 ms |
39760 KB |
Output is correct |
4 |
Correct |
8 ms |
39760 KB |
Output is correct |
5 |
Correct |
8 ms |
39760 KB |
Output is correct |
6 |
Correct |
9 ms |
39760 KB |
Output is correct |
7 |
Correct |
8 ms |
39760 KB |
Output is correct |
8 |
Correct |
7 ms |
39760 KB |
Output is correct |
9 |
Correct |
8 ms |
39760 KB |
Output is correct |
10 |
Correct |
8 ms |
39760 KB |
Output is correct |
11 |
Correct |
8 ms |
39760 KB |
Output is correct |
12 |
Correct |
8 ms |
39868 KB |
Output is correct |
13 |
Correct |
9 ms |
40016 KB |
Output is correct |
14 |
Correct |
9 ms |
40016 KB |
Output is correct |
15 |
Correct |
9 ms |
40036 KB |
Output is correct |
16 |
Correct |
9 ms |
40016 KB |
Output is correct |
17 |
Correct |
10 ms |
39868 KB |
Output is correct |
18 |
Correct |
9 ms |
40016 KB |
Output is correct |
19 |
Correct |
9 ms |
40040 KB |
Output is correct |
20 |
Correct |
9 ms |
40016 KB |
Output is correct |
21 |
Correct |
9 ms |
40016 KB |
Output is correct |
22 |
Correct |
175 ms |
52048 KB |
Output is correct |
23 |
Correct |
171 ms |
52556 KB |
Output is correct |
24 |
Correct |
201 ms |
53984 KB |
Output is correct |
25 |
Correct |
299 ms |
59720 KB |
Output is correct |
26 |
Correct |
161 ms |
52296 KB |
Output is correct |
27 |
Correct |
335 ms |
59720 KB |
Output is correct |
28 |
Correct |
307 ms |
59704 KB |
Output is correct |
29 |
Correct |
155 ms |
52120 KB |
Output is correct |
30 |
Correct |
115 ms |
49304 KB |
Output is correct |
31 |
Correct |
131 ms |
50224 KB |
Output is correct |
32 |
Correct |
261 ms |
57008 KB |
Output is correct |
33 |
Correct |
116 ms |
49588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
39760 KB |
Output is correct |
2 |
Correct |
9 ms |
39760 KB |
Output is correct |
3 |
Correct |
9 ms |
39760 KB |
Output is correct |
4 |
Correct |
10 ms |
39760 KB |
Output is correct |
5 |
Correct |
9 ms |
39872 KB |
Output is correct |
6 |
Correct |
9 ms |
40016 KB |
Output is correct |
7 |
Correct |
10 ms |
40016 KB |
Output is correct |
8 |
Correct |
127 ms |
49440 KB |
Output is correct |
9 |
Correct |
141 ms |
50100 KB |
Output is correct |
10 |
Correct |
276 ms |
57020 KB |
Output is correct |
11 |
Correct |
120 ms |
49612 KB |
Output is correct |
12 |
Correct |
101 ms |
44988 KB |
Output is correct |
13 |
Correct |
95 ms |
44736 KB |
Output is correct |
14 |
Correct |
78 ms |
44996 KB |
Output is correct |
15 |
Correct |
82 ms |
44992 KB |
Output is correct |
16 |
Correct |
81 ms |
45124 KB |
Output is correct |
17 |
Correct |
85 ms |
44996 KB |
Output is correct |
18 |
Correct |
543 ms |
65836 KB |
Output is correct |
19 |
Correct |
562 ms |
65976 KB |
Output is correct |
20 |
Correct |
434 ms |
66488 KB |
Output is correct |
21 |
Correct |
428 ms |
66480 KB |
Output is correct |
22 |
Correct |
449 ms |
66476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
39760 KB |
Output is correct |
2 |
Correct |
7 ms |
39760 KB |
Output is correct |
3 |
Correct |
9 ms |
39760 KB |
Output is correct |
4 |
Correct |
8 ms |
39760 KB |
Output is correct |
5 |
Correct |
8 ms |
39760 KB |
Output is correct |
6 |
Correct |
9 ms |
39760 KB |
Output is correct |
7 |
Correct |
8 ms |
39760 KB |
Output is correct |
8 |
Correct |
7 ms |
39760 KB |
Output is correct |
9 |
Correct |
8 ms |
39760 KB |
Output is correct |
10 |
Correct |
8 ms |
39760 KB |
Output is correct |
11 |
Correct |
8 ms |
39760 KB |
Output is correct |
12 |
Correct |
8 ms |
39868 KB |
Output is correct |
13 |
Correct |
9 ms |
40016 KB |
Output is correct |
14 |
Correct |
9 ms |
40016 KB |
Output is correct |
15 |
Correct |
9 ms |
40036 KB |
Output is correct |
16 |
Correct |
9 ms |
40016 KB |
Output is correct |
17 |
Correct |
10 ms |
39868 KB |
Output is correct |
18 |
Correct |
9 ms |
40016 KB |
Output is correct |
19 |
Correct |
9 ms |
40040 KB |
Output is correct |
20 |
Correct |
9 ms |
40016 KB |
Output is correct |
21 |
Correct |
9 ms |
40016 KB |
Output is correct |
22 |
Correct |
91 ms |
44360 KB |
Output is correct |
23 |
Correct |
94 ms |
44356 KB |
Output is correct |
24 |
Correct |
127 ms |
46340 KB |
Output is correct |
25 |
Correct |
130 ms |
46408 KB |
Output is correct |
26 |
Correct |
111 ms |
47780 KB |
Output is correct |
27 |
Correct |
109 ms |
47824 KB |
Output is correct |
28 |
Correct |
102 ms |
45640 KB |
Output is correct |
29 |
Correct |
107 ms |
47432 KB |
Output is correct |
30 |
Correct |
120 ms |
46244 KB |
Output is correct |
31 |
Correct |
123 ms |
46408 KB |
Output is correct |
32 |
Correct |
117 ms |
46664 KB |
Output is correct |
33 |
Correct |
120 ms |
46932 KB |
Output is correct |
34 |
Correct |
112 ms |
45952 KB |
Output is correct |
35 |
Correct |
118 ms |
45956 KB |
Output is correct |
36 |
Correct |
112 ms |
46180 KB |
Output is correct |
37 |
Correct |
96 ms |
44988 KB |
Output is correct |
38 |
Correct |
96 ms |
44736 KB |
Output is correct |
39 |
Correct |
83 ms |
44944 KB |
Output is correct |
40 |
Correct |
88 ms |
44992 KB |
Output is correct |
41 |
Correct |
81 ms |
44996 KB |
Output is correct |
42 |
Correct |
77 ms |
44992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
39760 KB |
Output is correct |
2 |
Correct |
7 ms |
39760 KB |
Output is correct |
3 |
Correct |
9 ms |
39760 KB |
Output is correct |
4 |
Correct |
8 ms |
39760 KB |
Output is correct |
5 |
Correct |
8 ms |
39760 KB |
Output is correct |
6 |
Correct |
9 ms |
39760 KB |
Output is correct |
7 |
Correct |
8 ms |
39760 KB |
Output is correct |
8 |
Correct |
7 ms |
39760 KB |
Output is correct |
9 |
Correct |
8 ms |
39760 KB |
Output is correct |
10 |
Correct |
8 ms |
39760 KB |
Output is correct |
11 |
Correct |
8 ms |
39760 KB |
Output is correct |
12 |
Correct |
8 ms |
39868 KB |
Output is correct |
13 |
Correct |
9 ms |
40016 KB |
Output is correct |
14 |
Correct |
9 ms |
40016 KB |
Output is correct |
15 |
Correct |
9 ms |
40036 KB |
Output is correct |
16 |
Correct |
9 ms |
40016 KB |
Output is correct |
17 |
Correct |
10 ms |
39868 KB |
Output is correct |
18 |
Correct |
9 ms |
40016 KB |
Output is correct |
19 |
Correct |
9 ms |
40040 KB |
Output is correct |
20 |
Correct |
9 ms |
40016 KB |
Output is correct |
21 |
Correct |
9 ms |
40016 KB |
Output is correct |
22 |
Correct |
175 ms |
52048 KB |
Output is correct |
23 |
Correct |
171 ms |
52556 KB |
Output is correct |
24 |
Correct |
201 ms |
53984 KB |
Output is correct |
25 |
Correct |
299 ms |
59720 KB |
Output is correct |
26 |
Correct |
161 ms |
52296 KB |
Output is correct |
27 |
Correct |
335 ms |
59720 KB |
Output is correct |
28 |
Correct |
307 ms |
59704 KB |
Output is correct |
29 |
Correct |
155 ms |
52120 KB |
Output is correct |
30 |
Correct |
115 ms |
49304 KB |
Output is correct |
31 |
Correct |
131 ms |
50224 KB |
Output is correct |
32 |
Correct |
261 ms |
57008 KB |
Output is correct |
33 |
Correct |
116 ms |
49588 KB |
Output is correct |
34 |
Correct |
8 ms |
39760 KB |
Output is correct |
35 |
Correct |
9 ms |
39760 KB |
Output is correct |
36 |
Correct |
9 ms |
39760 KB |
Output is correct |
37 |
Correct |
10 ms |
39760 KB |
Output is correct |
38 |
Correct |
9 ms |
39872 KB |
Output is correct |
39 |
Correct |
9 ms |
40016 KB |
Output is correct |
40 |
Correct |
10 ms |
40016 KB |
Output is correct |
41 |
Correct |
127 ms |
49440 KB |
Output is correct |
42 |
Correct |
141 ms |
50100 KB |
Output is correct |
43 |
Correct |
276 ms |
57020 KB |
Output is correct |
44 |
Correct |
120 ms |
49612 KB |
Output is correct |
45 |
Correct |
101 ms |
44988 KB |
Output is correct |
46 |
Correct |
95 ms |
44736 KB |
Output is correct |
47 |
Correct |
78 ms |
44996 KB |
Output is correct |
48 |
Correct |
82 ms |
44992 KB |
Output is correct |
49 |
Correct |
81 ms |
45124 KB |
Output is correct |
50 |
Correct |
85 ms |
44996 KB |
Output is correct |
51 |
Correct |
543 ms |
65836 KB |
Output is correct |
52 |
Correct |
562 ms |
65976 KB |
Output is correct |
53 |
Correct |
434 ms |
66488 KB |
Output is correct |
54 |
Correct |
428 ms |
66480 KB |
Output is correct |
55 |
Correct |
449 ms |
66476 KB |
Output is correct |
56 |
Correct |
91 ms |
44360 KB |
Output is correct |
57 |
Correct |
94 ms |
44356 KB |
Output is correct |
58 |
Correct |
127 ms |
46340 KB |
Output is correct |
59 |
Correct |
130 ms |
46408 KB |
Output is correct |
60 |
Correct |
111 ms |
47780 KB |
Output is correct |
61 |
Correct |
109 ms |
47824 KB |
Output is correct |
62 |
Correct |
102 ms |
45640 KB |
Output is correct |
63 |
Correct |
107 ms |
47432 KB |
Output is correct |
64 |
Correct |
120 ms |
46244 KB |
Output is correct |
65 |
Correct |
123 ms |
46408 KB |
Output is correct |
66 |
Correct |
117 ms |
46664 KB |
Output is correct |
67 |
Correct |
120 ms |
46932 KB |
Output is correct |
68 |
Correct |
112 ms |
45952 KB |
Output is correct |
69 |
Correct |
118 ms |
45956 KB |
Output is correct |
70 |
Correct |
112 ms |
46180 KB |
Output is correct |
71 |
Correct |
96 ms |
44988 KB |
Output is correct |
72 |
Correct |
96 ms |
44736 KB |
Output is correct |
73 |
Correct |
83 ms |
44944 KB |
Output is correct |
74 |
Correct |
88 ms |
44992 KB |
Output is correct |
75 |
Correct |
81 ms |
44996 KB |
Output is correct |
76 |
Correct |
77 ms |
44992 KB |
Output is correct |
77 |
Correct |
751 ms |
73800 KB |
Output is correct |
78 |
Correct |
742 ms |
73864 KB |
Output is correct |
79 |
Correct |
707 ms |
81484 KB |
Output is correct |
80 |
Correct |
710 ms |
81464 KB |
Output is correct |
81 |
Correct |
566 ms |
79176 KB |
Output is correct |
82 |
Correct |
606 ms |
80712 KB |
Output is correct |
83 |
Correct |
702 ms |
73800 KB |
Output is correct |
84 |
Correct |
653 ms |
73668 KB |
Output is correct |
85 |
Correct |
723 ms |
74764 KB |
Output is correct |
86 |
Correct |
719 ms |
70344 KB |
Output is correct |
87 |
Correct |
674 ms |
69612 KB |
Output is correct |
88 |
Correct |
662 ms |
78096 KB |
Output is correct |