博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
面积并
阅读量:6629 次
发布时间:2019-06-25

本文共 2852 字,大约阅读时间需要 9 分钟。

3835: Crop Circles 分享至QQ空间

Time Limit(Common/Java):1000MS/3000MS     Memory Limit:65536KByte
Total Submit: 101            Accepted:70

Description

 

Bessie and her fellow herd-mates have become extremely territorial. The N (1 <= N <= 400) cows conveniently numbered 1..N have all staked out a grazing spot in the pasture. Each cow i has a spot on an integer grid (0 <= X_i <= 10,000; 0 <= Y_i <= 10,000) and an integer radius R_i that indicates the circle she is staking out (1 <= R_i <= 500).

The cows are a bit greedy and sometimes stake out territory of their herd-mates. For each cow, calculate the number of other cows whose territory overlaps her territory.
By way of example, consider these six cows with indicated locations and radii (don't confuse radius with diameter!):

By visual inspection, we can see and count the overlaps, as shown.

NOTE: the test data will avoid pathological situations like tangents where the circles just barely touch.
 

 

Input

 

* Line 1: A single integer: N

* Lines 2..N+1: Three space-separated integers: X_i, Y_i, and R_i
 

 

Output

 

* Lines 1..N: Line i contains a single integer that is the number of other fields that overlap with cow i's field.

 

 

Sample Input

6

7 7 7
16 14 7
11 13 2
10 17 3
29 8 5
15 7 4

Sample Output

3

4
3
2
0
2

Source

Toj的一个题,问题只是n个圆和自己交的有多少个

 

#include 
int x[410],y[410],r[410];int main(){ int n,i,j; scanf("%d",&n); for(i=0; i

 

 

 

矩形面积并,线段树经典

2719: 覆盖的面积 分享至QQ空间

Time Limit(Common/Java):2000MS/20000MS     Memory Limit:65536KByte
Total Submit: 13            Accepted:10

Description

给定平面上若干矩形,求出被这些矩形覆盖过至少两次的区域的面积.

 

Input

输入数据的第一行是一个正整数T(1<=T<=100),代表测试数据的数量.每个测试数据的第一行是一个正整数N(1<=N<=1000),代表矩形的数量,然后是N行数据,每一行包含四个浮点数,代表平面上的一个矩形的左上角坐标和右下角坐标,矩形的上下边和X轴平行,左右边和Y轴平行.坐标的范围从0到100000.

注意:本题的输入数据较多,推荐使用scanf读入数据.

Output

对于每组测试数据,请计算出被这些矩形覆盖过至少两次的区域的面积.结果保留两位小数.

Sample Input

2

5
1 1 4 2
1 3 3 7
2 1.5 5 4.5
3.5 1.25 7.5 4
6 3 10 7
3
0 0 1 1
1 0 2 1
2 0 3 1

Sample Output

7.63

0.00

用先sort+二分离散化,再用线段树维护左右端点

#include 
#include
using namespace std;const int N=2005;struct seg{ double l,r,h; int v; bool friend operator <(seg u,seg v) { return u.h
1)q[i].len=has[q[i].r+1]-has[q[i].l]; else if(q[i].l==q[i].r)q[i].len=0; else if(q[i].cnt==1)q[i].len=q[i*2].s+q[i*2+1].s; else q[i].len=q[i*2].len+q[i*2+1].len;}void update(int l,int r,int f,int i){ if(q[i].l==l&&q[i].r==r) { q[i].cnt+=f; pushup(i); return; } int mid=(q[i].l+q[i].r)/2; if(r<=mid)update(l,r,f,i*2); else if(l>mid)update(l,r,f,i*2+1); else { update(l,mid,f,i*2); update(mid+1,r,f,i*2+1); } pushup(i);}int main(){ int T; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); int k=0; for(int i=0; i

 

转载于:https://www.cnblogs.com/BobHuang/p/7389301.html

你可能感兴趣的文章
go练习4--json 序列号反序列化
查看>>
urllib2抓取HTML存入Excel
查看>>
mysql group by 组内排序
查看>>
Lua利用cjson读写json
查看>>
偶然发现的android2.2的一个bug
查看>>
tomcat解决加载JSP文件过大错误
查看>>
算法图解之快速排序
查看>>
Codeforces Round #410 (Div. 2) B. Mike and strings
查看>>
Android -- 仿淘宝广告条滚动
查看>>
printf()参数的处理
查看>>
[Groovy] 在Groovy中优雅的实现do while
查看>>
[翻译]Brainfuck
查看>>
Deep Learning
查看>>
C语言 自定义字符串拼接函数
查看>>
页面滑动到一定距离导航固定及回到顶部
查看>>
新盘进行LVM的划分
查看>>
Day14 JavaScript
查看>>
模块化一小步,编译的一大步
查看>>
java 数组初始化
查看>>
python之MySQL学习——简单的增删改查封装
查看>>