1 solutions
-
0
接雨滴(glory)
原题:qoj5819。
我们考虑雨滴不动而人去动。可以发现,一个人在 处一秒内能走到的位置是 到 。那么,我们离线下来每个点,然后从每个点出发画两条方向为 和 的射线,这两条射线围起来的面积就是从这个点出发能够到达的所有点。
由于所有点出发的两条斜线斜率分别相同,所以我们改变坐标系,将这两条斜线当作 轴,就变为了一个二维偏序问题,离散化后树状数组维护。复杂度 。
#include<bits/stdc++.h> #define re register #define int long long using namespace std; const int N=5e5+5; int n,q,s,vc,vg,vw,y[N],tr[N],ans[N]; struct point{ int t,p,x,y,id; bool operator<(const point& CXK)const{ return x>CXK.x||x==CXK.x&&y>CXK.y; } }c[N],ask[N]; inline void update(int x,int k){ for(;x<=n;x+=x&-x) tr[x]=max(tr[x],k); } inline int getmax(int x){ int res=0; for(;x>0;x-=x&-x) res=max(res,tr[x]); return res; } void Init(){ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); cin>>n>>q>>vg>>vw>>vc; for(re int i=1;i<=n;i++){ int x,y; cin>>x>>y; c[i]={y,x*vg+y*vw,0,0,0}; } for(re int i=1;i<=n;i++){ c[i].x=vc*c[i].t-c[i].p; c[i].y=y[i]=vc*c[i].t+c[i].p; } } signed main(){ freopen("glory.in", "r", stdin); freopen("glory.out", "w", stdout); Init(); for(re int i=1;i<=q;i++){ cin>>s; s*=vg; ask[i]={0,s,-s,s,i}; } sort(y+1,y+n+1); sort(c+1,c+n+1); sort(ask+1,ask+q+1); for(re int i=1,j=1;i<=q;i++){ int ay=lower_bound(y+1,y+n+1,ask[i].y)-y; while(c[j].x>=ask[i].x&&j<=n){ c[j].y=lower_bound(y+1,y+n+1,c[j].y)-y; update(n-c[j].y+1,getmax(n-c[j].y+1)+1); j++; } ans[ask[i].id]=getmax(n-ay+1); } for(int i=1;i<=q;i++) cout<<ans[i]<<'\n'; return 0; }
- 1
Information
- ID
- 70
- Time
- 1000ms
- Memory
- 512MiB
- Difficulty
- 9
- Tags
- (None)
- # Submissions
- 24
- Accepted
- 3
- Uploaded By