# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1104194 |
2024-10-23T08:32:02 Z |
8pete8 |
Curtains (NOI23_curtains) |
C++17 |
|
714 ms |
58552 KB |
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<cassert>
#include<unordered_map>
#include <queue>
#include <cstdint>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
#define int long long
using namespace std;
const int mod=998244353,mxn=5e5+5,inf=1e18,minf=-1e18,lg=20;
//#undef int
int n,k,m,q;
void setIO(string name){
ios_base::sync_with_stdio(0); cin.tie(0);
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
struct seg{
int v[4*mxn+10],lazy[4*mxn+10];
void build(int l,int r,int pos){
v[pos]=lazy[pos]=inf;
if(l==r)return;
int mid=l+(r-l)/2;
build(l,mid,pos*2);
build(mid+1,r,pos*2+1);
}
void push(int l,int r,int pos){
v[pos]=min(v[pos],lazy[pos]);
if(l!=r){
lazy[pos*2]=min(lazy[pos*2],lazy[pos]);
lazy[pos*2+1]=min(lazy[pos*2+1],lazy[pos]);
}
lazy[pos]=inf;
}
void updaterange(int l,int r,int pos,int ql,int qr,int val){
push(l,r,pos);
if(l>qr||r<ql)return;
if(l>=ql&&r<=qr){
lazy[pos]=val;
push(l,r,pos);
return;
}
int mid=l+(r-l)/2;
updaterange(l,mid,pos*2,ql,qr,val);
updaterange(mid+1,r,pos*2+1,ql,qr,val);
v[pos]=max(v[pos*2],v[pos*2+1]);
}
int qryrange(int l,int r,int pos,int ql,int qr){
push(l,r,pos);
if(l>qr||r<ql)return minf;
if(l>=ql&&r<=qr)return v[pos];
int mid=l+(r-l)/2;
return max(qryrange(l,mid,pos*2,ql,qr),qryrange(mid+1,r,pos*2+1,ql,qr));
}
}t;
int ans[mxn+10];
int32_t main(){
fastio
cin>>n>>m>>q;
vector<pii>v;
for(int i=0;i<m;i++){
int a,b;cin>>a>>b;
v.pb({a,b});
}
t.build(1,n,1);
sort(rall(v));
vector<pair<pii,int>>qry(q);
for(int i=0;i<q;i++)cin>>qry[i].f.f>>qry[i].f.s,qry[i].s=i;
sort(rall(qry));
int cur=0;
for(auto i:qry){
while(cur<v.size()&&v[cur].f>=i.f.f){
//activate cur
t.updaterange(1,n,1,v[cur].f,v[cur].s,v[cur].s);
cur++;
}
ans[i.s]=(t.qryrange(1,n,1,i.f.f,i.f.s)<=i.f.s);
}
for(int i=0;i<q;i++){
if(ans[i])cout<<"YES\n";
else cout<<"NO\n";
}
}
/*
*/
Compilation message
curtains.cpp:32:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
32 | #pragma GCC optimize ("03,unroll-lopps")
| ^
curtains.cpp:38:23: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
38 | void setIO(string name){
| ^
curtains.cpp:45:32: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
45 | void build(int l,int r,int pos){
| ^
curtains.cpp:52:31: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
52 | void push(int l,int r,int pos){
| ^
curtains.cpp:60:60: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
60 | void updaterange(int l,int r,int pos,int ql,int qr,int val){
| ^
curtains.cpp:73:48: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
73 | int qryrange(int l,int r,int pos,int ql,int qr){
| ^
curtains.cpp:82:14: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
82 | int32_t main(){
| ^
curtains.cpp: In function 'int32_t main()':
curtains.cpp:97:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
97 | while(cur<v.size()&&v[cur].f>=i.f.f){
| ~~~^~~~~~~~~
curtains.cpp: In function 'void setIO(std::string)':
curtains.cpp:40:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | freopen((name+".in").c_str(),"r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:41:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
41 | freopen((name+".out").c_str(),"w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4664 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
4432 KB |
Output is correct |
7 |
Correct |
1 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
4432 KB |
Output is correct |
9 |
Correct |
1 ms |
4608 KB |
Output is correct |
10 |
Correct |
2 ms |
4600 KB |
Output is correct |
11 |
Correct |
1 ms |
4432 KB |
Output is correct |
12 |
Correct |
1 ms |
4600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4664 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
4432 KB |
Output is correct |
7 |
Correct |
1 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
4432 KB |
Output is correct |
9 |
Correct |
1 ms |
4608 KB |
Output is correct |
10 |
Correct |
2 ms |
4600 KB |
Output is correct |
11 |
Correct |
1 ms |
4432 KB |
Output is correct |
12 |
Correct |
1 ms |
4600 KB |
Output is correct |
13 |
Correct |
4 ms |
4688 KB |
Output is correct |
14 |
Correct |
3 ms |
4688 KB |
Output is correct |
15 |
Correct |
3 ms |
4688 KB |
Output is correct |
16 |
Correct |
3 ms |
4688 KB |
Output is correct |
17 |
Correct |
3 ms |
4688 KB |
Output is correct |
18 |
Correct |
3 ms |
4688 KB |
Output is correct |
19 |
Correct |
3 ms |
4688 KB |
Output is correct |
20 |
Correct |
3 ms |
4584 KB |
Output is correct |
21 |
Correct |
3 ms |
4856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4664 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
4432 KB |
Output is correct |
7 |
Correct |
1 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
4432 KB |
Output is correct |
9 |
Correct |
1 ms |
4608 KB |
Output is correct |
10 |
Correct |
2 ms |
4600 KB |
Output is correct |
11 |
Correct |
1 ms |
4432 KB |
Output is correct |
12 |
Correct |
1 ms |
4600 KB |
Output is correct |
13 |
Correct |
4 ms |
4688 KB |
Output is correct |
14 |
Correct |
3 ms |
4688 KB |
Output is correct |
15 |
Correct |
3 ms |
4688 KB |
Output is correct |
16 |
Correct |
3 ms |
4688 KB |
Output is correct |
17 |
Correct |
3 ms |
4688 KB |
Output is correct |
18 |
Correct |
3 ms |
4688 KB |
Output is correct |
19 |
Correct |
3 ms |
4688 KB |
Output is correct |
20 |
Correct |
3 ms |
4584 KB |
Output is correct |
21 |
Correct |
3 ms |
4856 KB |
Output is correct |
22 |
Correct |
193 ms |
24392 KB |
Output is correct |
23 |
Correct |
206 ms |
25068 KB |
Output is correct |
24 |
Correct |
252 ms |
27840 KB |
Output is correct |
25 |
Correct |
408 ms |
37428 KB |
Output is correct |
26 |
Correct |
203 ms |
24648 KB |
Output is correct |
27 |
Correct |
388 ms |
37452 KB |
Output is correct |
28 |
Correct |
379 ms |
37432 KB |
Output is correct |
29 |
Correct |
177 ms |
24392 KB |
Output is correct |
30 |
Correct |
153 ms |
23624 KB |
Output is correct |
31 |
Correct |
164 ms |
24772 KB |
Output is correct |
32 |
Correct |
347 ms |
36272 KB |
Output is correct |
33 |
Correct |
137 ms |
24012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4432 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
2 ms |
4688 KB |
Output is correct |
6 |
Correct |
2 ms |
4688 KB |
Output is correct |
7 |
Correct |
2 ms |
4860 KB |
Output is correct |
8 |
Correct |
153 ms |
23664 KB |
Output is correct |
9 |
Correct |
150 ms |
24772 KB |
Output is correct |
10 |
Correct |
310 ms |
36272 KB |
Output is correct |
11 |
Correct |
140 ms |
23876 KB |
Output is correct |
12 |
Correct |
82 ms |
17620 KB |
Output is correct |
13 |
Correct |
83 ms |
17612 KB |
Output is correct |
14 |
Correct |
70 ms |
17600 KB |
Output is correct |
15 |
Correct |
66 ms |
17424 KB |
Output is correct |
16 |
Correct |
65 ms |
17620 KB |
Output is correct |
17 |
Correct |
65 ms |
17544 KB |
Output is correct |
18 |
Correct |
488 ms |
55872 KB |
Output is correct |
19 |
Correct |
528 ms |
55728 KB |
Output is correct |
20 |
Correct |
415 ms |
55624 KB |
Output is correct |
21 |
Correct |
381 ms |
55552 KB |
Output is correct |
22 |
Correct |
385 ms |
55548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4664 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
4432 KB |
Output is correct |
7 |
Correct |
1 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
4432 KB |
Output is correct |
9 |
Correct |
1 ms |
4608 KB |
Output is correct |
10 |
Correct |
2 ms |
4600 KB |
Output is correct |
11 |
Correct |
1 ms |
4432 KB |
Output is correct |
12 |
Correct |
1 ms |
4600 KB |
Output is correct |
13 |
Correct |
4 ms |
4688 KB |
Output is correct |
14 |
Correct |
3 ms |
4688 KB |
Output is correct |
15 |
Correct |
3 ms |
4688 KB |
Output is correct |
16 |
Correct |
3 ms |
4688 KB |
Output is correct |
17 |
Correct |
3 ms |
4688 KB |
Output is correct |
18 |
Correct |
3 ms |
4688 KB |
Output is correct |
19 |
Correct |
3 ms |
4688 KB |
Output is correct |
20 |
Correct |
3 ms |
4584 KB |
Output is correct |
21 |
Correct |
3 ms |
4856 KB |
Output is correct |
22 |
Correct |
90 ms |
13504 KB |
Output is correct |
23 |
Correct |
95 ms |
13552 KB |
Output is correct |
24 |
Correct |
111 ms |
17856 KB |
Output is correct |
25 |
Correct |
115 ms |
17976 KB |
Output is correct |
26 |
Correct |
97 ms |
17896 KB |
Output is correct |
27 |
Correct |
96 ms |
18056 KB |
Output is correct |
28 |
Correct |
74 ms |
16068 KB |
Output is correct |
29 |
Correct |
86 ms |
17676 KB |
Output is correct |
30 |
Correct |
108 ms |
17856 KB |
Output is correct |
31 |
Correct |
133 ms |
17856 KB |
Output is correct |
32 |
Correct |
107 ms |
17856 KB |
Output is correct |
33 |
Correct |
85 ms |
17868 KB |
Output is correct |
34 |
Correct |
95 ms |
18112 KB |
Output is correct |
35 |
Correct |
95 ms |
17856 KB |
Output is correct |
36 |
Correct |
118 ms |
17856 KB |
Output is correct |
37 |
Correct |
83 ms |
17600 KB |
Output is correct |
38 |
Correct |
85 ms |
17672 KB |
Output is correct |
39 |
Correct |
65 ms |
17436 KB |
Output is correct |
40 |
Correct |
66 ms |
17600 KB |
Output is correct |
41 |
Correct |
81 ms |
17604 KB |
Output is correct |
42 |
Correct |
65 ms |
17600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4664 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
4432 KB |
Output is correct |
7 |
Correct |
1 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
4432 KB |
Output is correct |
9 |
Correct |
1 ms |
4608 KB |
Output is correct |
10 |
Correct |
2 ms |
4600 KB |
Output is correct |
11 |
Correct |
1 ms |
4432 KB |
Output is correct |
12 |
Correct |
1 ms |
4600 KB |
Output is correct |
13 |
Correct |
4 ms |
4688 KB |
Output is correct |
14 |
Correct |
3 ms |
4688 KB |
Output is correct |
15 |
Correct |
3 ms |
4688 KB |
Output is correct |
16 |
Correct |
3 ms |
4688 KB |
Output is correct |
17 |
Correct |
3 ms |
4688 KB |
Output is correct |
18 |
Correct |
3 ms |
4688 KB |
Output is correct |
19 |
Correct |
3 ms |
4688 KB |
Output is correct |
20 |
Correct |
3 ms |
4584 KB |
Output is correct |
21 |
Correct |
3 ms |
4856 KB |
Output is correct |
22 |
Correct |
193 ms |
24392 KB |
Output is correct |
23 |
Correct |
206 ms |
25068 KB |
Output is correct |
24 |
Correct |
252 ms |
27840 KB |
Output is correct |
25 |
Correct |
408 ms |
37428 KB |
Output is correct |
26 |
Correct |
203 ms |
24648 KB |
Output is correct |
27 |
Correct |
388 ms |
37452 KB |
Output is correct |
28 |
Correct |
379 ms |
37432 KB |
Output is correct |
29 |
Correct |
177 ms |
24392 KB |
Output is correct |
30 |
Correct |
153 ms |
23624 KB |
Output is correct |
31 |
Correct |
164 ms |
24772 KB |
Output is correct |
32 |
Correct |
347 ms |
36272 KB |
Output is correct |
33 |
Correct |
137 ms |
24012 KB |
Output is correct |
34 |
Correct |
1 ms |
4432 KB |
Output is correct |
35 |
Correct |
1 ms |
4432 KB |
Output is correct |
36 |
Correct |
1 ms |
4444 KB |
Output is correct |
37 |
Correct |
1 ms |
4432 KB |
Output is correct |
38 |
Correct |
2 ms |
4688 KB |
Output is correct |
39 |
Correct |
2 ms |
4688 KB |
Output is correct |
40 |
Correct |
2 ms |
4860 KB |
Output is correct |
41 |
Correct |
153 ms |
23664 KB |
Output is correct |
42 |
Correct |
150 ms |
24772 KB |
Output is correct |
43 |
Correct |
310 ms |
36272 KB |
Output is correct |
44 |
Correct |
140 ms |
23876 KB |
Output is correct |
45 |
Correct |
82 ms |
17620 KB |
Output is correct |
46 |
Correct |
83 ms |
17612 KB |
Output is correct |
47 |
Correct |
70 ms |
17600 KB |
Output is correct |
48 |
Correct |
66 ms |
17424 KB |
Output is correct |
49 |
Correct |
65 ms |
17620 KB |
Output is correct |
50 |
Correct |
65 ms |
17544 KB |
Output is correct |
51 |
Correct |
488 ms |
55872 KB |
Output is correct |
52 |
Correct |
528 ms |
55728 KB |
Output is correct |
53 |
Correct |
415 ms |
55624 KB |
Output is correct |
54 |
Correct |
381 ms |
55552 KB |
Output is correct |
55 |
Correct |
385 ms |
55548 KB |
Output is correct |
56 |
Correct |
90 ms |
13504 KB |
Output is correct |
57 |
Correct |
95 ms |
13552 KB |
Output is correct |
58 |
Correct |
111 ms |
17856 KB |
Output is correct |
59 |
Correct |
115 ms |
17976 KB |
Output is correct |
60 |
Correct |
97 ms |
17896 KB |
Output is correct |
61 |
Correct |
96 ms |
18056 KB |
Output is correct |
62 |
Correct |
74 ms |
16068 KB |
Output is correct |
63 |
Correct |
86 ms |
17676 KB |
Output is correct |
64 |
Correct |
108 ms |
17856 KB |
Output is correct |
65 |
Correct |
133 ms |
17856 KB |
Output is correct |
66 |
Correct |
107 ms |
17856 KB |
Output is correct |
67 |
Correct |
85 ms |
17868 KB |
Output is correct |
68 |
Correct |
95 ms |
18112 KB |
Output is correct |
69 |
Correct |
95 ms |
17856 KB |
Output is correct |
70 |
Correct |
118 ms |
17856 KB |
Output is correct |
71 |
Correct |
83 ms |
17600 KB |
Output is correct |
72 |
Correct |
85 ms |
17672 KB |
Output is correct |
73 |
Correct |
65 ms |
17436 KB |
Output is correct |
74 |
Correct |
66 ms |
17600 KB |
Output is correct |
75 |
Correct |
81 ms |
17604 KB |
Output is correct |
76 |
Correct |
65 ms |
17600 KB |
Output is correct |
77 |
Correct |
607 ms |
58056 KB |
Output is correct |
78 |
Correct |
622 ms |
58068 KB |
Output is correct |
79 |
Correct |
520 ms |
58552 KB |
Output is correct |
80 |
Correct |
517 ms |
58544 KB |
Output is correct |
81 |
Correct |
498 ms |
57788 KB |
Output is correct |
82 |
Correct |
566 ms |
57936 KB |
Output is correct |
83 |
Correct |
698 ms |
58176 KB |
Output is correct |
84 |
Correct |
714 ms |
58040 KB |
Output is correct |
85 |
Correct |
639 ms |
58032 KB |
Output is correct |
86 |
Correct |
571 ms |
57792 KB |
Output is correct |
87 |
Correct |
576 ms |
57004 KB |
Output is correct |
88 |
Correct |
550 ms |
57776 KB |
Output is correct |