Codeforces 198E
来源:互联网 发布:手机淘宝社区在哪 编辑:程序博客网 时间:2024/05/29 03:59
线段树+set
这样就可以保证,每个爪子只被拿走一次,并且只更新一次,
并且更新的复杂度总的来说为
#include <cstdio>#include <iostream>#include <algorithm>#include <set>using namespace std;int i,j,k,X,Y,all,tot,n,M[250011],P[250011],R[250011],Left[500011],Right[500011],PP[250011],dl[250011],sum[500011];long long x,y,p,r,D[250011],RR[250011];bool used[250011];set<pair<int,int> > ent[500011];bool cmp(int a,int b){ return D[a]<D[b];}void build(int s,int e,int now){ sum[now]=e-s+1; for (int i=s; i<=e; i++) ent[now].insert(pair<int,int>(M[dl[i]],dl[i])); if (s==e) return ; int mid=(s+e)/2; Left[now]=++tot; build(s,mid,tot); Right[now]=++tot; build(mid+1,e,tot);}void quick(long long A,int b,int l,int r,int now){ if (sum[now]==0 || D[dl[l]]>A) return ; if (D[dl[r]]<=A){ set<pair<int,int> >::iterator cp; while (sum[now] && ent[now].begin()->first<=b){ cp=ent[now].begin(); int o=cp->second; if (!used[o]) { used[o]=true; PP[++all]=P[o]; RR[all]=(long long)R[o]*R[o]; } ent[now].erase(cp); sum[now]--; } return ; } int mid=(l+r)/2; quick(A,b,l,mid,Left[now]); if (D[dl[mid+1]]<=A) quick(A,b,mid+1,r,Right[now]);}int main(){ cin >> x >> y >> p >> r >> n; for (i=1; i<=n; i++) scanf("%d%d%d%d%d",&X,&Y,&M[i],&P[i],&R[i]),D[i]=(X-x)*(X-x)+(Y-y)*(Y-y),dl[i]=i; sort(dl+1,dl+n+1,cmp); build(1,n,0); PP[0]=p; RR[0]=r*r; for (i=0; all<=n && i<=all; i++) quick(RR[i],PP[i],1,n,0); cout << all; return 0;}
0 0
- Codeforces 198E
- Codeforces Problemset 198E(#125 div.1 E)
- codeforces 163E e-Government
- 【Codeforces 163E】E-Government
- Codeforces 78E Evacuation
- 【dp】codeforces 83E
- Codeforces 124 E
- Codeforces 231E
- Codeforces 231E - Cactus
- Codeforces #163 Div2 E
- codeForces 35E
- Codeforces 35E
- Playlist codeforces 268E
- Codeforces 148E(Porcelain)
- codeforces round#177 E
- codeforces 203E Transportation
- CodeForces 254 E Dormitory
- codeforces日记371e
- TranslateAnimation详解
- immutable的作用和在react中的应用
- Linux shell 里面的数学计算
- [置顶] iOS学习笔记-环信UI3.0集成中的问题
- 符号三角形
- Codeforces 198E
- 进程和线程的区别
- C#启动其它程序
- c/c++ 动态申请数组
- 使用jpa报No query defined for that name错误
- Unity3D教程:如何利用Shader实现钻石渲染效果
- [BFS Tarjan_LCA 生成树] CERC 2016 H Hangar Hurdles
- 慎用Distinct
- python镜像