4561 [JLoi2016] 圆的异或并
来源:互联网 发布:电影同声语音翻译软件 编辑:程序博客网 时间:2024/06/07 00:02
4561: [JLoi2016]圆的异或并
Time Limit: 30 Sec Memory Limit: 256 MB
Submit: 565 Solved: 239
[Submit][Status][Discuss]
Description
在平面直角坐标系中给定N个圆。已知这些圆两两没有交点,即两圆的关系只存在相离和包含。求这些圆的异或面
积并。异或面积并为:当一片区域在奇数个圆内则计算其面积,当一片区域在偶数个圆内则不考虑。
Input
第一行包含一个正整数N,代表圆的个数。接下来N行,每行3个非负整数x,y,r,表示一个圆心在(x,y),半径为r的
圆。保证|x|,|y|,≤10^8,r>0,N<=200000
Output
仅一行一个整数,表示所有圆的异或面积并除以圆周率Pi的结果。
Sample Input
2
0 0 1
0 0 2
Sample Output
3
HINT
Source
【分析】
把每个圆拆成上半圆和下半圆,由于拆圆后各个半圆的相对位置不会变化,所以可以用扫描线+平衡树来维护。
【代码】
//bzoj 4561#include<bits/stdc++.h>#define ll long long#define fo(i,j,k) for(i=j;i<=k;i++)using namespace std;const int mxn=200005;ll n,m,T;ll f[mxn];struct circle {ll x,y,r;} c[mxn];struct ope {ll num,x,f;} b[mxn<<1];inline bool comp(ope x,ope y) {return x.x<y.x;}inline ll F(ll x) {return x*x;}inline bool operator < (ope x,ope y){ double xx=c[x.num].y+x.f*sqrt(F(c[x.num].r)-F(T-c[x.num].x)); double yy=c[y.num].y+y.f*sqrt(F(c[y.num].r)-F(T-c[y.num].x)); if(xx!=yy) return xx<yy;return x.f<y.f;}set <ope> S;int main(){ ll i,j; scanf("%lld",&n); fo(i,1,n) { scanf("%lld%lld%lld",&c[i].x,&c[i].y,&c[i].r); b[2*i-1]=(ope){i,c[i].x-c[i].r,1}; b[2*i]=(ope){i,c[i].x+c[i].r,-1}; } sort(b+1,b+n+n+1,comp); set <ope>::iterator it; fo(i,1,n+n) { T=b[i].x; if(b[i].f==1) { it=S.upper_bound((ope){b[i].num,0,1}); if(it==S.end()) f[b[i].num]=1; else { if((*it).f==1) f[b[i].num]=-f[(*it).num]; else f[b[i].num]=f[(*it).num]; } S.insert((ope){b[i].num,0,-1}); S.insert((ope){b[i].num,0,1}); } else { S.erase((ope){b[i].num,0,-1}); S.erase((ope){b[i].num,0,1}); } } ll ans=0; fo(i,1,n) ans+=f[i]*F(c[i].r); printf("%lld\n",ans); return 0;}
阅读全文
1 0
- 4561: [JLoi2016]圆的异或并
- 4561 [JLoi2016] 圆的异或并
- BZOJ4561 [JLoi2016]圆的异或并
- [JLOI2016] 圆的异或并
- BZOJ4561: [JLoi2016]圆的异或并
- bzoj4561【JLOI2016】圆的异或并
- BZOJ 4561 [JLoi2016]圆的异或并
- 【bzoj4561】【JLOI2016】【圆的异或并】【扫描线+set】
- [扫描线 set] BZOJ 4561 [JLoi2016]圆的异或并
- bzoj 4561: [JLoi2016]圆的异或并 (计算几何+扫描线+splay)
- bzoj 4561: [JLoi2016]圆的异或并(扫描线+set)
- [BZOJ4561][JLoi2016]圆的异或并(扫描线+splay)
- 【BZOJ 4561】【JLOI 2016】圆的异或并
- 【LNOI/JLOI/SHOI2016】【BZOJ4561】圆的异或并
- la4487 加权并查集,异或的性质
- shell中并,或的用法
- UVALive 4487 异或 并查集
- JLOI2016酱油记
- selenium2java通过第三方登录绕过知乎登陆验证码
- IDEA 本地git库项目关联及码云项目上传下载
- java环境配置
- Weex语法体验
- Swift3.0 监控键盘的弹出与收回
- 4561 [JLoi2016] 圆的异或并
- Python3.X 爬虫实战(动态页面爬取解析)
- 25张图让你读懂神经网络架构
- 程序字符集问题
- rabbitmq(安装)
- 比特位操作——二进制表示
- CString分割切分 实现SplitCString
- 剑指offer-数值的整数次方
- Ubuntu 安装dbus-python 错误解决