Submission #1104194

#TimeUsernameProblemLanguageResultExecution timeMemory
11041948pete8Curtains (NOI23_curtains)C++17
100 / 100
714 ms58552 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...