# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1102770 |
2024-10-18T20:02:49 Z |
ttamx |
Curtains (NOI23_curtains) |
C++17 |
|
743 ms |
73036 KB |
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
const int K=1<<20;
const int INF=INT_MAX/2;
int n,m,q;
vector<int> upd[N];
vector<pair<int,int>> qrs[N];
bool ans[N];
struct SegTree{
struct Node{
int mn,mn2;
Node():mn(0),mn2(INF){}
Node(int _mn,int _mn2):mn(_mn),mn2(_mn2){}
friend Node operator+(const Node &lhs,const Node &rhs){
if(lhs.mn<rhs.mn)return Node(lhs.mn,min(rhs.mn,lhs.mn2));
if(lhs.mn>rhs.mn)return Node(rhs.mn,min(lhs.mn,rhs.mn2));
return Node(lhs.mn,min(lhs.mn2,rhs.mn2));
}
void chmax(int v){
if(v<=mn)return;
mn=v;
if(mn>=mn2)mn2=INF;
}
}t[K];
void push(int i){
t[i*2].chmax(t[i].mn);
t[i*2+1].chmax(t[i].mn);
}
void update(int l,int r,int i,int x,int y,int v){
if(y<l||r<x||t[i].mn>=v)return;
if(x<=l&&r<=y&&t[i].mn2>v)return t[i].chmax(v);
push(i);
int m=(l+r)/2;
update(l,m,i*2,x,y,v);
update(m+1,r,i*2+1,x,y,v);
t[i]=t[i*2]+t[i*2+1];
}
void update(int x,int y,int v){
update(1,n,1,x,y,v);
}
int query(int l,int r,int i,int x,int y){
if(y<l||r<x)return INF;
if(x<=l&&r<=y)return t[i].mn;
push(i);
int m=(l+r)/2;
return min(query(l,m,i*2,x,y),query(m+1,r,i*2+1,x,y));
}
int query(int x,int y){
return query(1,n,1,x,y);
}
}seg;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> m >> q;
for(int i=0;i<m;i++){
int l,r;
cin >> l >> r;
upd[r].emplace_back(l);
}
for(int i=0;i<q;i++){
int l,r;
cin >> l >> r;
qrs[r].emplace_back(l,i);
}
for(int r=1;r<=n;r++){
for(auto l:upd[r]){
seg.update(l,r,l);
}
for(auto [l,i]:qrs[r]){
ans[i]=(seg.query(l,r)>=l);
}
}
for(int i=0;i<q;i++){
cout << (ans[i]?"YES":"NO") << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
32596 KB |
Output is correct |
2 |
Correct |
6 ms |
32596 KB |
Output is correct |
3 |
Correct |
6 ms |
32596 KB |
Output is correct |
4 |
Correct |
6 ms |
32596 KB |
Output is correct |
5 |
Correct |
6 ms |
32596 KB |
Output is correct |
6 |
Correct |
7 ms |
32596 KB |
Output is correct |
7 |
Correct |
7 ms |
32640 KB |
Output is correct |
8 |
Correct |
7 ms |
32596 KB |
Output is correct |
9 |
Correct |
6 ms |
32596 KB |
Output is correct |
10 |
Correct |
8 ms |
32596 KB |
Output is correct |
11 |
Correct |
7 ms |
32408 KB |
Output is correct |
12 |
Correct |
7 ms |
32596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
32596 KB |
Output is correct |
2 |
Correct |
6 ms |
32596 KB |
Output is correct |
3 |
Correct |
6 ms |
32596 KB |
Output is correct |
4 |
Correct |
6 ms |
32596 KB |
Output is correct |
5 |
Correct |
6 ms |
32596 KB |
Output is correct |
6 |
Correct |
7 ms |
32596 KB |
Output is correct |
7 |
Correct |
7 ms |
32640 KB |
Output is correct |
8 |
Correct |
7 ms |
32596 KB |
Output is correct |
9 |
Correct |
6 ms |
32596 KB |
Output is correct |
10 |
Correct |
8 ms |
32596 KB |
Output is correct |
11 |
Correct |
7 ms |
32408 KB |
Output is correct |
12 |
Correct |
7 ms |
32596 KB |
Output is correct |
13 |
Correct |
10 ms |
32596 KB |
Output is correct |
14 |
Correct |
9 ms |
32596 KB |
Output is correct |
15 |
Correct |
9 ms |
32596 KB |
Output is correct |
16 |
Correct |
9 ms |
32596 KB |
Output is correct |
17 |
Correct |
9 ms |
32760 KB |
Output is correct |
18 |
Correct |
9 ms |
32596 KB |
Output is correct |
19 |
Correct |
8 ms |
32596 KB |
Output is correct |
20 |
Correct |
8 ms |
32596 KB |
Output is correct |
21 |
Correct |
8 ms |
32596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
32596 KB |
Output is correct |
2 |
Correct |
6 ms |
32596 KB |
Output is correct |
3 |
Correct |
6 ms |
32596 KB |
Output is correct |
4 |
Correct |
6 ms |
32596 KB |
Output is correct |
5 |
Correct |
6 ms |
32596 KB |
Output is correct |
6 |
Correct |
7 ms |
32596 KB |
Output is correct |
7 |
Correct |
7 ms |
32640 KB |
Output is correct |
8 |
Correct |
7 ms |
32596 KB |
Output is correct |
9 |
Correct |
6 ms |
32596 KB |
Output is correct |
10 |
Correct |
8 ms |
32596 KB |
Output is correct |
11 |
Correct |
7 ms |
32408 KB |
Output is correct |
12 |
Correct |
7 ms |
32596 KB |
Output is correct |
13 |
Correct |
10 ms |
32596 KB |
Output is correct |
14 |
Correct |
9 ms |
32596 KB |
Output is correct |
15 |
Correct |
9 ms |
32596 KB |
Output is correct |
16 |
Correct |
9 ms |
32596 KB |
Output is correct |
17 |
Correct |
9 ms |
32760 KB |
Output is correct |
18 |
Correct |
9 ms |
32596 KB |
Output is correct |
19 |
Correct |
8 ms |
32596 KB |
Output is correct |
20 |
Correct |
8 ms |
32596 KB |
Output is correct |
21 |
Correct |
8 ms |
32596 KB |
Output is correct |
22 |
Correct |
141 ms |
44744 KB |
Output is correct |
23 |
Correct |
144 ms |
45136 KB |
Output is correct |
24 |
Correct |
162 ms |
46412 KB |
Output is correct |
25 |
Correct |
282 ms |
52300 KB |
Output is correct |
26 |
Correct |
154 ms |
44776 KB |
Output is correct |
27 |
Correct |
271 ms |
52300 KB |
Output is correct |
28 |
Correct |
275 ms |
52300 KB |
Output is correct |
29 |
Correct |
125 ms |
43888 KB |
Output is correct |
30 |
Correct |
89 ms |
43948 KB |
Output is correct |
31 |
Correct |
106 ms |
44876 KB |
Output is correct |
32 |
Correct |
224 ms |
51532 KB |
Output is correct |
33 |
Correct |
88 ms |
44108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
32576 KB |
Output is correct |
2 |
Correct |
7 ms |
32596 KB |
Output is correct |
3 |
Correct |
7 ms |
32596 KB |
Output is correct |
4 |
Correct |
7 ms |
32596 KB |
Output is correct |
5 |
Correct |
9 ms |
32676 KB |
Output is correct |
6 |
Correct |
10 ms |
32596 KB |
Output is correct |
7 |
Correct |
8 ms |
32596 KB |
Output is correct |
8 |
Correct |
92 ms |
44092 KB |
Output is correct |
9 |
Correct |
103 ms |
44876 KB |
Output is correct |
10 |
Correct |
219 ms |
51284 KB |
Output is correct |
11 |
Correct |
96 ms |
44108 KB |
Output is correct |
12 |
Correct |
99 ms |
39756 KB |
Output is correct |
13 |
Correct |
99 ms |
39756 KB |
Output is correct |
14 |
Correct |
81 ms |
39824 KB |
Output is correct |
15 |
Correct |
94 ms |
39500 KB |
Output is correct |
16 |
Correct |
82 ms |
39756 KB |
Output is correct |
17 |
Correct |
82 ms |
39504 KB |
Output is correct |
18 |
Correct |
609 ms |
69768 KB |
Output is correct |
19 |
Correct |
615 ms |
69964 KB |
Output is correct |
20 |
Correct |
534 ms |
70476 KB |
Output is correct |
21 |
Correct |
486 ms |
69584 KB |
Output is correct |
22 |
Correct |
507 ms |
68840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
32596 KB |
Output is correct |
2 |
Correct |
6 ms |
32596 KB |
Output is correct |
3 |
Correct |
6 ms |
32596 KB |
Output is correct |
4 |
Correct |
6 ms |
32596 KB |
Output is correct |
5 |
Correct |
6 ms |
32596 KB |
Output is correct |
6 |
Correct |
7 ms |
32596 KB |
Output is correct |
7 |
Correct |
7 ms |
32640 KB |
Output is correct |
8 |
Correct |
7 ms |
32596 KB |
Output is correct |
9 |
Correct |
6 ms |
32596 KB |
Output is correct |
10 |
Correct |
8 ms |
32596 KB |
Output is correct |
11 |
Correct |
7 ms |
32408 KB |
Output is correct |
12 |
Correct |
7 ms |
32596 KB |
Output is correct |
13 |
Correct |
10 ms |
32596 KB |
Output is correct |
14 |
Correct |
9 ms |
32596 KB |
Output is correct |
15 |
Correct |
9 ms |
32596 KB |
Output is correct |
16 |
Correct |
9 ms |
32596 KB |
Output is correct |
17 |
Correct |
9 ms |
32760 KB |
Output is correct |
18 |
Correct |
9 ms |
32596 KB |
Output is correct |
19 |
Correct |
8 ms |
32596 KB |
Output is correct |
20 |
Correct |
8 ms |
32596 KB |
Output is correct |
21 |
Correct |
8 ms |
32596 KB |
Output is correct |
22 |
Correct |
92 ms |
36952 KB |
Output is correct |
23 |
Correct |
92 ms |
36948 KB |
Output is correct |
24 |
Correct |
116 ms |
38944 KB |
Output is correct |
25 |
Correct |
117 ms |
38988 KB |
Output is correct |
26 |
Correct |
100 ms |
40108 KB |
Output is correct |
27 |
Correct |
107 ms |
40360 KB |
Output is correct |
28 |
Correct |
79 ms |
37964 KB |
Output is correct |
29 |
Correct |
90 ms |
39756 KB |
Output is correct |
30 |
Correct |
113 ms |
38988 KB |
Output is correct |
31 |
Correct |
118 ms |
39044 KB |
Output is correct |
32 |
Correct |
117 ms |
39500 KB |
Output is correct |
33 |
Correct |
101 ms |
39756 KB |
Output is correct |
34 |
Correct |
112 ms |
38476 KB |
Output is correct |
35 |
Correct |
123 ms |
38732 KB |
Output is correct |
36 |
Correct |
102 ms |
39244 KB |
Output is correct |
37 |
Correct |
105 ms |
39640 KB |
Output is correct |
38 |
Correct |
128 ms |
39756 KB |
Output is correct |
39 |
Correct |
83 ms |
39824 KB |
Output is correct |
40 |
Correct |
96 ms |
39500 KB |
Output is correct |
41 |
Correct |
72 ms |
39760 KB |
Output is correct |
42 |
Correct |
75 ms |
39500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
32596 KB |
Output is correct |
2 |
Correct |
6 ms |
32596 KB |
Output is correct |
3 |
Correct |
6 ms |
32596 KB |
Output is correct |
4 |
Correct |
6 ms |
32596 KB |
Output is correct |
5 |
Correct |
6 ms |
32596 KB |
Output is correct |
6 |
Correct |
7 ms |
32596 KB |
Output is correct |
7 |
Correct |
7 ms |
32640 KB |
Output is correct |
8 |
Correct |
7 ms |
32596 KB |
Output is correct |
9 |
Correct |
6 ms |
32596 KB |
Output is correct |
10 |
Correct |
8 ms |
32596 KB |
Output is correct |
11 |
Correct |
7 ms |
32408 KB |
Output is correct |
12 |
Correct |
7 ms |
32596 KB |
Output is correct |
13 |
Correct |
10 ms |
32596 KB |
Output is correct |
14 |
Correct |
9 ms |
32596 KB |
Output is correct |
15 |
Correct |
9 ms |
32596 KB |
Output is correct |
16 |
Correct |
9 ms |
32596 KB |
Output is correct |
17 |
Correct |
9 ms |
32760 KB |
Output is correct |
18 |
Correct |
9 ms |
32596 KB |
Output is correct |
19 |
Correct |
8 ms |
32596 KB |
Output is correct |
20 |
Correct |
8 ms |
32596 KB |
Output is correct |
21 |
Correct |
8 ms |
32596 KB |
Output is correct |
22 |
Correct |
141 ms |
44744 KB |
Output is correct |
23 |
Correct |
144 ms |
45136 KB |
Output is correct |
24 |
Correct |
162 ms |
46412 KB |
Output is correct |
25 |
Correct |
282 ms |
52300 KB |
Output is correct |
26 |
Correct |
154 ms |
44776 KB |
Output is correct |
27 |
Correct |
271 ms |
52300 KB |
Output is correct |
28 |
Correct |
275 ms |
52300 KB |
Output is correct |
29 |
Correct |
125 ms |
43888 KB |
Output is correct |
30 |
Correct |
89 ms |
43948 KB |
Output is correct |
31 |
Correct |
106 ms |
44876 KB |
Output is correct |
32 |
Correct |
224 ms |
51532 KB |
Output is correct |
33 |
Correct |
88 ms |
44108 KB |
Output is correct |
34 |
Correct |
6 ms |
32576 KB |
Output is correct |
35 |
Correct |
7 ms |
32596 KB |
Output is correct |
36 |
Correct |
7 ms |
32596 KB |
Output is correct |
37 |
Correct |
7 ms |
32596 KB |
Output is correct |
38 |
Correct |
9 ms |
32676 KB |
Output is correct |
39 |
Correct |
10 ms |
32596 KB |
Output is correct |
40 |
Correct |
8 ms |
32596 KB |
Output is correct |
41 |
Correct |
92 ms |
44092 KB |
Output is correct |
42 |
Correct |
103 ms |
44876 KB |
Output is correct |
43 |
Correct |
219 ms |
51284 KB |
Output is correct |
44 |
Correct |
96 ms |
44108 KB |
Output is correct |
45 |
Correct |
99 ms |
39756 KB |
Output is correct |
46 |
Correct |
99 ms |
39756 KB |
Output is correct |
47 |
Correct |
81 ms |
39824 KB |
Output is correct |
48 |
Correct |
94 ms |
39500 KB |
Output is correct |
49 |
Correct |
82 ms |
39756 KB |
Output is correct |
50 |
Correct |
82 ms |
39504 KB |
Output is correct |
51 |
Correct |
609 ms |
69768 KB |
Output is correct |
52 |
Correct |
615 ms |
69964 KB |
Output is correct |
53 |
Correct |
534 ms |
70476 KB |
Output is correct |
54 |
Correct |
486 ms |
69584 KB |
Output is correct |
55 |
Correct |
507 ms |
68840 KB |
Output is correct |
56 |
Correct |
92 ms |
36952 KB |
Output is correct |
57 |
Correct |
92 ms |
36948 KB |
Output is correct |
58 |
Correct |
116 ms |
38944 KB |
Output is correct |
59 |
Correct |
117 ms |
38988 KB |
Output is correct |
60 |
Correct |
100 ms |
40108 KB |
Output is correct |
61 |
Correct |
107 ms |
40360 KB |
Output is correct |
62 |
Correct |
79 ms |
37964 KB |
Output is correct |
63 |
Correct |
90 ms |
39756 KB |
Output is correct |
64 |
Correct |
113 ms |
38988 KB |
Output is correct |
65 |
Correct |
118 ms |
39044 KB |
Output is correct |
66 |
Correct |
117 ms |
39500 KB |
Output is correct |
67 |
Correct |
101 ms |
39756 KB |
Output is correct |
68 |
Correct |
112 ms |
38476 KB |
Output is correct |
69 |
Correct |
123 ms |
38732 KB |
Output is correct |
70 |
Correct |
102 ms |
39244 KB |
Output is correct |
71 |
Correct |
105 ms |
39640 KB |
Output is correct |
72 |
Correct |
128 ms |
39756 KB |
Output is correct |
73 |
Correct |
83 ms |
39824 KB |
Output is correct |
74 |
Correct |
96 ms |
39500 KB |
Output is correct |
75 |
Correct |
72 ms |
39760 KB |
Output is correct |
76 |
Correct |
75 ms |
39500 KB |
Output is correct |
77 |
Correct |
740 ms |
66324 KB |
Output is correct |
78 |
Correct |
743 ms |
66368 KB |
Output is correct |
79 |
Correct |
588 ms |
72780 KB |
Output is correct |
80 |
Correct |
575 ms |
73036 KB |
Output is correct |
81 |
Correct |
567 ms |
70800 KB |
Output is correct |
82 |
Correct |
549 ms |
72012 KB |
Output is correct |
83 |
Correct |
718 ms |
66396 KB |
Output is correct |
84 |
Correct |
730 ms |
66400 KB |
Output is correct |
85 |
Correct |
704 ms |
67968 KB |
Output is correct |
86 |
Correct |
650 ms |
64568 KB |
Output is correct |
87 |
Correct |
656 ms |
64216 KB |
Output is correct |
88 |
Correct |
583 ms |
70988 KB |
Output is correct |