A - Archery Tournament 动态开点+vecotor 神仙题
存图还是像矩形一样的存,每个节点存所在区级内部的圆的编号,然后暴力判断,开始我也有这个想法,但是。。。这TM也能过。。。仔细想想,貌似好像是可以过,时间复杂度玄学无法证明。。。。
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<set>
#include<vector>
#define LL long long
using namespace std;
const int maxx = 2e5+;
vector<int>v[maxx*];
int xx[maxx];
int yy[maxx];
struct node
{
int l,r;
} tree[maxx*];
int cnt;
int ans;
bool check(int x1,int y1,int x2,int y2)
{
return 1LL*(x1-x2)*(x1-x2)+1LL*(y1-y2)*(y1-y2)<1LL*y1*y1;
}
void buildtree(int &rt,int l,int r,int L,int R,int id)
{
if (!rt)
{
cnt++;
rt=cnt;
}
if (L<=l && r<=R)
{
v[rt].push_back(id);
return ;
}
int mid=(l+r)>>;
if (L<=mid)
{
buildtree(tree[rt].l,l,mid,L,R,id);
}
if (R>mid)
{
buildtree(tree[rt].r,mid+,r,L,R,id);
}
}
void query(int rt,int l,int r,int x,int y)
{
if (!rt)return;
for (auto it:v[rt])
{
if(check(xx[it],yy[it],x,y))
{
ans=it;
return ;
}
}
if (l==r)
{
return ;
}
int mid=(l+r)>>;
if (x<=mid)
{
query(tree[rt].l,l,mid,x,y);
}
else
{
query(tree[rt].r,mid+,r,x,y);
}
}
void update(int rt,int l,int r,int ul,int ur,int id)
{
if (ul>ur)return;
if (ul<=l && r<=ur)
{
vector<int>tmp;
for (auto it:v[rt])
{
if (it!=id)
{
tmp.push_back(it);
}
}
v[rt]=tmp;
return ;
}
int mid=(l+r)>>;
if (ul<=mid)
{
update(tree[rt].l,l,mid,ul,ur,id);
}
if (ur>mid)
{
update(tree[rt].r,mid+,r,ul,ur,id);
}
}
int main()
{
int t,op;
int rt;
while(~scanf("%d",&t))
{
cnt=;
rt=;
for (int i=; i<=t; i++)
{
scanf("%d%d%d",&op,&xx[i],&yy[i]);
if (op==)
{
buildtree(rt,-1e9,1e9,xx[i]-yy[i],xx[i]+yy[i],i);
}
else
{
ans=-;
query(rt,-1e9,1e9,xx[i],yy[i]);
printf("%d\n",ans);
if (ans!=-)
{
update(rt,-1e9,1e9,xx[ans]-yy[ans],xx[ans]+yy[ans],ans);
}
}
}
}
return ;
}
A - Archery Tournament 动态开点+vecotor 神仙题的更多相关文章
- [ZJOI2019]语言(树链剖分+动态开点线段树+启发式合并)
首先,对于从每个点出发的路径,答案一定是过这个点的路径所覆盖的点数.然后可以做树上差分,对每个点记录路径产生总贡献,然后做一个树剖维护,对每个点维护一个动态开点线段树.最后再从根节点开始做一遍dfs, ...
- 【模板】【P3605】【USACO17JAN】Promotion Counting 晋升者计数——动态开点和线段树合并(树状数组/主席树)
(题面来自Luogu) 题目描述 奶牛们又一次试图创建一家创业公司,还是没有从过去的经验中吸取教训--牛是可怕的管理者! 为了方便,把奶牛从 1⋯N(1≤N≤100,000) 编号,把公司组织成一棵树 ...
- [2016湖南长沙培训Day4][前鬼后鬼的守护 chen] (动态开点线段树+中位数 or 动规 or 贪心+堆优化)
题目大意 给定一个长度为n的正整数序列,令修改一个数的代价为修改前后两个数的绝对值之差,求用最小代价将序列转换为不减序列. 其中,n满足小于500000,序列中的正整数小于10^9 题解(引自mzx神 ...
- [bzoj 3531][SDOI2014]旅行(树链剖分+动态开点线段树)
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=3531 分析: 对于每个颜色(颜色<=10^5)都建立一颗线段树 什么!那么不是M ...
- 【BZOJ-4636】蒟蒻的数列 动态开点线段树 ||(离散化) + 标记永久化
4636: 蒟蒻的数列 Time Limit: 30 Sec Memory Limit: 256 MBSubmit: 247 Solved: 113[Submit][Status][Discuss ...
- CF731C Socks并查集(森林),连边,贪心,森林遍历方式,动态开点释放内存
http://codeforces.com/problemset/problem/731/C 这个题的题意是..小明的妈妈给小明留下了n只袜子,给你一个大小为n的颜色序列c 代表第i只袜子的颜色,小明 ...
- 【BZOJ3531】[Sdoi2014]旅行 树链剖分+动态开点线段树
[BZOJ3531][Sdoi2014]旅行 Description S国有N个城市,编号从1到N.城市间用N-1条双向道路连接,满足从一个城市出发可以到达其它所有城市.每个城市信仰不同的宗教,如飞天 ...
- BZOJ_4636_蒟蒻的数列_线段树+动态开点
BZOJ_4636_蒟蒻的数列_线段树+动态开点 Description 蒟蒻DCrusher不仅喜欢玩扑克,还喜欢研究数列 题目描述 DCrusher有一个数列,初始值均为0,他进行N次操作,每次将 ...
- codeforces 893F - Physical Education Lessons 动态开点线段树合并
https://codeforces.com/contest/893/problem/F 题意: 给一个有根树, 多次查询,每次查询对于$x$i点的子树中,距离$x$小于等于$k$的所有点中权值最小的 ...
随机推荐
- 20190921-雅礼Day1
#error 此人太蒻无法编译 #include<iostream> main(){} Before 哦…… -O2 T1 序列问题:分块(莫队),树状数组,线段树,分治 离线 or 在线 ...
- SPSS正交设计的操作
SPSS正交设计的操作 设要做二因素的正交设计,A因素有三个水平,B因素有两个水平.则选择Data-->Orthogonal Design-->generate,弹出的就是正交设计窗口: ...
- [jnhs]全套CRC校验 算法
摘自 https://blog.csdn.net/cp1300/article/details/51443350 uint8_t crc4_itu(uint8_t *data, uint_len le ...
- Elasticsearch连接类(带密码)
/** * 获取ES连接类 * * @author 陈康 * @description * @create 2019/08/15 **/ @Component("ElasticsearchR ...
- Leetcode16.3Sum Closest最接近的三数之和
给定一个包括 n 个整数的数组 nums 和 一个目标值 target.找出 nums 中的三个整数,使得它们的和与 target 最接近.返回这三个数的和.假定每组输入只存在唯一答案. 例如,给定数 ...
- 一些windows server的操作
windows server2008R2的一些操作和arcgis9.3 服务和arcgis9.3安装 1.在虚拟机中安装: https://jingyan.baidu.com/article/0eb4 ...
- php手册常用的函数
<?php ************************************************************/ header("Content-type:tex ...
- JavaScript--事件委托--冒泡
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 数据库lib7第4题创建存储过程
1. 传入2个字符串变量,其中,每个字符串是用分号(:)分隔的字串形式, 比如str1=’ab12;ab;cccc;tty’, str2=’1;6sf;8fffff;dd’, 注意,字符串是用户输入的 ...
- linux的简单操作
查看当前用户who am i 创建用户:sudo adduser lilei然后输入密码 查看用户:ls /home 用新用户登陆:su -l lilei 查看所属用户组:groups 用户名 新建文 ...