제출 #998865

#제출 시각아이디문제언어결과실행 시간메모리
998865modwweGift Exchange (JOI24_ho_t4)C++17
100 / 100
1091 ms73160 KiB
///https://www.instagram.com/_modwwe/ #include<bits/stdc++.h> //#define int long long //#define ll long long #define down cout<<'\n'; #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".ans","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; void phongbeo(); const int mod2=1e9+7; const int mod1=998244353; struct icd { int a,b; }; struct ib { int a; int b; }; struct ic { int a,b,c; }; struct id { int a,b,c,d; }; struct ie { int a,b,c, d,e,f; }; int n,m,s1,s2,s4,s3,sf,k,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l; int i,s10,s12; int el=29; main() { #ifndef ONLINE_JUDGE //fin(task),fou(task); #endif NHP /// cin>>s1; // modwwe phongbeo(),down } ib a[500001]; int b[500001]; struct IT { int t[2000001],lazy[2000001]; void build(int node,int l,int r) { t[node]=0; lazy[node]=0; if(l==r) return; int mid=l+r>>1; build(node<<1,l,mid); build(node<<1|1,mid+1,r); } void ff(int x) { for(int i=x*2; i<=x*2+1; i++) t[i]=max(t[i],lazy[x]), lazy[i]=max(lazy[i],lazy[x]); } void upd(int node,int l,int r,int l1,int r1,int x) { if(l>r1||r<l1) return; if(l>=l1&&r<=r1) { t[node]=max(x,t[node]); lazy[node]=max(lazy[node],x); return; } int mid=l+r>>1; ff(node); upd(node<<1,l,mid,l1,r1,x); upd(node<<1|1,mid+1,r,l1,r1,x); t[node]=max(t[node<<1],t[node<<1|1]); } int get(int node,int l,int r,int l1,int r1) { if(l>r1||r<l1) return 0; if(l>=l1&&r<=r1) return t[node]; ff(node); int mid=l+r>>1; return max(get(node<<1,l,mid,l1,r1),get(node<<1|1,mid+1,r,l1,r1)); } } st1; struct IC { int t[2000001]; void ff(int x) { for(int i=x*2; i<=x*2+1; i++) t[i]+=t[x]; t[x]=0; } void upd(int node,int l,int r,int l1,int r1,int x) { if(l>r1||r<l1) return; if(l>=l1&&r<=r1) { t[node]+=x; return; } int mid=l+r>>1; ff(node); upd(node<<1,l,mid,l1,r1,x); upd(node<<1|1,mid+1,r,l1,r1,x); } int get(int node,int l,int r,int l1,int r1) { if(l>r1||r<l1) return 0; if(l>=l1&&r<=r1) return t[node]; ff(node); int mid=l+r>>1; return get(node<<1,l,mid,l1,r1)+get(node<<1|1,mid+1,r,l1,r1); } } st2; /// sort theo a neu ai<bj&(ai-1)<bi (j>i) /** sort(l->r) check for i: task1: a(i-1)<bi task 2: min(bi+1,br)>ai => bi->ai =0 */ vector<ic> v2[500002]; vector<ib> v3[500002]; void solve1() { for(int i=1; i<=n; i++) b[i]=st1.get(1,1,n,a[i].b,a[i].a)+1, st1.upd(1,1,n,a[i].b,a[i].a,i); } void solve2() { st1.build(1,1,n); for(int i=1; i<=n; i++) s3=st1.get(1,1,n,a[i].b,a[i].a), v2[b[n-i+1]].pb({n-i+1,n-s3,1}), v2[n-i+2].pb({n-i+1,n-s3,-1}), st1.upd(1,1,n,a[i].b,a[i].a,i); } vector<int> v; int ans[200001]; void phongbeo() { cin>>n; for(int i=1; i<=n; i++) cin>>a[i].a,v.pb(a[i].a); sort(v.begin(),v.end()); for(int i=1; i<=n; i++) cin>>a[i].b, a[i].a=lower_bound(v.begin(),v.end(),a[i].a)-v.begin()+1, a[i].b=lower_bound(v.begin(),v.end(),a[i].b)-v.begin()+1; solve1(); reverse(a+1,a+1+n); solve2(); cin>>m; for(int i=1; i<=m; i++) cin>>l>>r,v3[l].pb({r,i}); for(int i=1; i<=n; i++) { for(auto x:v2[i]) st2.upd(1,1,n,x.a,x.b,x.c); for(auto x:v3[i]) ans[x.b]=st2.get(1,1,n,x.a,x.a); } for(int i=1; i<=m; i++) if(ans[i]>=1) cout<<"No",down else cout<<"Yes",down } /** 10 12 14 16 17 6 11 13 9 3 */

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   44 | main()
      | ^~~~
Main.cpp: In member function 'void IT::build(int, int, int)':
Main.cpp:65:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   65 |         int mid=l+r>>1;
      |                 ~^~
Main.cpp: In member function 'void IT::upd(int, int, int, int, int, int)':
Main.cpp:85:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   85 |         int mid=l+r>>1;
      |                 ~^~
Main.cpp: In member function 'int IT::get(int, int, int, int, int)':
Main.cpp:96:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   96 |         int mid=l+r>>1;
      |                 ~^~
Main.cpp: In member function 'void IC::upd(int, int, int, int, int, int)':
Main.cpp:117:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  117 |         int mid=l+r>>1;
      |                 ~^~
Main.cpp: In member function 'int IC::get(int, int, int, int, int)':
Main.cpp:127:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  127 |         int mid=l+r>>1;
      |                 ~^~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...