Submission #933264

#TimeUsernameProblemLanguageResultExecution timeMemory
933264yeediotCurtains (NOI23_curtains)C++14
100 / 100
1037 ms95196 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define F first #define S second #define all(x) x.begin(),x.end() #define pii pair<int,int> #define pb push_back #define sz(x) (int)(x.size()) #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) #define vi vector<int> #define vp vector<pii> #define vvi vector<vi> #define ykh mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()) #define __lg(x) 63-__builtin_clzll(x) #define pow2(x) (1LL<<x) void __print(int x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifdef local void setio(){freopen("/Users/iantsai/Library/Mobile Documents/com~apple~CloudDocs/cpp/Empty.md","r",stdin);} #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #else void setio(){} #define debug(x...) #endif void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } struct line{ int a,b; int operator()(const int x)const{ return a*x+b; } }; bool check(line l1,line l2,line l3){ return (l3.b-l2.b)*(l1.a-l2.a)<=(l2.b-l1.b)*(l2.a-l3.a); } const int mxn=5e5+5; int seg[4*mxn]; int tag[4*mxn]; #define lc id*2 #define rc id*2+1 void push(int id){ seg[lc]=max(seg[lc],tag[id]); seg[rc]=max(seg[rc],tag[id]); tag[lc]=max(tag[lc],tag[id]); tag[rc]=max(tag[rc],tag[id]); tag[id]=0; } void modify(int l,int r,int id,int ql,int qr,int v){ if(qr<l or r<ql)return; if(ql<=l and r<=qr){ seg[id]=max(seg[id],v); tag[id]=max(tag[id],v); return; } int mm=l+r>>1; push(id); modify(l,mm,id*2,ql,qr,v); modify(mm+1,r,id*2+1,ql,qr,v); seg[id]=min(seg[id*2],seg[id*2+1]); } int query(int l,int r,int id,int ql,int qr){ if(qr<l or r<ql)return 8e18; if(ql<=l and r<=qr){ return seg[id]; } int mm=l+r>>1; push(id); return min(query(l,mm,id*2,ql,qr),query(mm+1,r,id*2+1,ql,qr)); } vector<pii>l[mxn],r[mxn]; signed main(){ setio(); ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n,m,q; cin>>n>>m>>q; vector<pii>cur,qq; for(int i=0;i<m;i++){ int ll,rr; cin>>ll>>rr; cur.pb({ll,rr}); r[rr].pb({i,0}); } for(int i=0;i<q;i++){ int ll,rr; cin>>ll>>rr; qq.pb({ll,rr}); r[rr].pb({i,1}); } vector<bool>ans(q); for(int i=1;i<mxn;i++){ for(auto [j,ty]:r[i]){ if(ty==0){ modify(1,n,1,cur[j].F,cur[j].S,cur[j].F); } else{ if(query(1,n,1,qq[j].F,qq[j].S)>=qq[j].F)ans[j]=1; else ans[j]=0; } } } for(auto i:ans){ if(i)cout<<"YES\n"; else cout<<"NO\n"; } } /* input: */

Compilation message (stderr)

curtains.cpp: In function 'void modify(long long int, long long int, long long int, long long int, long long int, long long int)':
curtains.cpp:73:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   73 |     int mm=l+r>>1;
      |            ~^~
curtains.cpp: In function 'long long int query(long long int, long long int, long long int, long long int, long long int)':
curtains.cpp:84:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   84 |     int mm=l+r>>1;
      |            ~^~
curtains.cpp: In function 'int main()':
curtains.cpp:110:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
  110 |         for(auto [j,ty]:r[i]){
      |                  ^
curtains.cpp: In function 'void setIO(std::string)':
curtains.cpp:42:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:43:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     freopen((s + ".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...