Mom and dad have a problem: their child, Reza, never puts his toys away when he is finished playing with them. They gave Reza a rectangular box to put his toys in. Unfortunately, Reza is rebellious and obeys his parents by simply throwing his toys into the box. All the toys get mixed up, and it is impossible for Reza to find his favorite toys anymore.
Reza's parents came up with the following idea. They put cardboard partitions into the box. Even if Reza keeps throwing his toys into the box, at least toys that get thrown into different partitions stay separate. The box looks like this from the top:

We want for each positive integer t, such that there exists a partition with t toys, determine how many partitions have t, toys.Input

The input consists of a number of cases. The first line consists of six integers n, m, x1, y1, x2, y2. The number of cardboards to form the partitions is n (0 < n <= 1000) and the number of toys is given in m (0 < m <= 1000). The coordinates of the upper-left corner and the lower-right corner of the box are (x1, y1) and (x2, y2), respectively. The following n lines each consists of two integers Ui Li, indicating that the ends of the ith cardboard is at the coordinates (Ui, y1) and (Li, y2). You may assume that the cardboards do not intersect with each other. The next m lines each consists of two integers Xi Yi specifying where the ith toy has landed in the box. You may assume that no toy will land on a cardboard.

A line consisting of a single 0 terminates the input.

Output

For each box, first provide a header stating "Box" on a line of its own. After that, there will be one line of output per count (t > 0) of toys in a partition. The value t will be followed by a colon and a space, followed the number of partitions containing t toys. Output will be sorted in ascending order of t for each box.

Sample Input

4 10 0 10 100 0
20 20
80 80
60 60
40 40
5 10
15 10
95 10
25 10
65 10
75 10
35 10
45 10
55 10
85 10
5 6 0 10 60 0
4 3
15 30
3 1
6 8
10 10
2 1
2 8
1 5
5 5
40 10
7 9
0

Sample Output

Box
2: 5
Box
1: 4
2: 1

和poj2318几乎一模一样,就是要排个序,二分就行了,判断二分状态用叉积
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007 using namespace std; const int N=,maxn=,inf=0x3f3f3f3f; struct point{
int x,y;
};
struct line{
point a,b;
}l[N];
int num[N],n,m,res[N]; bool comp(const line &u,const line &v)
{
if(u.a.x!=v.a.x)return u.a.x<v.a.x;
return u.a.y<v.a.y;
}
bool ok(int m,int x,int y)
{
float f=(l[m].b.x-l[m].a.x)*(y-l[m].a.y)-(l[m].b.y-l[m].a.y)*(x-l[m].a.x);
if(f>)return ;
return ;
}
void Bsearch(int u,int v)
{
int l=,r=n+;
for(int i=;i<;i++)
{
int mid=(l+r)/;
if(ok(mid,u,v))l=mid;
else r=mid;
}
num[l]++;
}
int main()
{
while(cin>>n,n){
memset(num,,sizeof(num));
cin>>m>>l[].a.x>>l[].a.y>>l[n+].b.x>>l[n+].b.y;
for(int i=;i<=n;i++)
{
cin>>l[i].a.x>>l[i].b.x;
l[i].a.y=l[].a.y;
l[i].b.y=l[n+].b.y;
}
sort(l,l+n+,comp);
for(int i=;i<m;i++)
{
int u,v;
cin>>u>>v;
Bsearch(u,v);
}
cout<<"Box"<<endl;
memset(res,,sizeof(res));
for(int i=;i<=n;i++)res[num[i]]++;
for(int i=;i<=n;i++)
if(res[i]!=)
cout<<i<<": "<<res[i]<<endl;
}
return ;
}

poj2398计算几何叉积的更多相关文章

  1. poj1039 Pipe(计算几何叉积求交点)

    F - Pipe Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Sta ...

  2. 【BZOJ1132】【POI2008】Tro 计算几何 叉积求面积

    链接: #include <stdio.h> int main() { puts("转载请注明出处[辗转山河弋流歌 by 空灰冰魂]谢谢"); puts("网 ...

  3. [ An Ac a Day ^_^ ] CodeForces 659D Bicycle Race 计算几何 叉积

    问有多少个点在多边形内 求一遍叉积 小于零计数就好了~ #include<stdio.h> #include<iostream> #include<algorithm&g ...

  4. poj 1654 Area(计算几何--叉积求多边形面积)

    一个简单的用叉积求任意多边形面积的题,并不难,但我却错了很多次,double的数据应该是要转化为long long,我转成了int...这里为了节省内存尽量不开数组,直接计算,我MLE了一发...,最 ...

  5. ACM/ICPC 之 计算几何入门-叉积-to left test(POJ2318-POJ2398)

    POJ2318 本题需要运用to left test不断判断点处于哪个分区,并统计分区的点个数(保证点不在边界和界外),用来做叉积入门题很合适 //计算几何-叉积入门题 //Time:157Ms Me ...

  6. 【自用】OI计划安排表一轮

    网络流√ 上下界最大流√ 线性规划转费用流√ RMQ优化建图√ 单纯形√ 字符串相关 hash√ 扩展KMP 回文自己主动机 数据结构 平衡树 启示式合并 替罪羊树 LCT 树套树 KD-Tree 二 ...

  7. poj2398 Toy Storage 计算几何,叉积,二分

    poj2398 Toy Storage 链接 poj 题目大意 这道题的大概意思是先输入6个数字:n,m,x1,y1,x2,y2.n代表卡片的数量,卡片竖直(或倾斜)放置在盒内,可把盒子分为n+1块区 ...

  8. TOYS - POJ 2318(计算几何,叉积判断)

    题目大意:给你一个矩形的左上角和右下角的坐标,然后这个矩形有 N 个隔板分割成 N+1 个区域,下面有 M 组坐标,求出来每个区域包含的坐标数.   分析:做的第一道计算几何题目....使用叉积判断方 ...

  9. hrbustoj 1318:蛋疼的蚂蚁(计算几何,凸包变种,叉积应用)

    蛋疼的蚂蚁 Time Limit: 1000 MS     Memory Limit: 65536 K Total Submit: 39(22 users)    Total Accepted: 26 ...

随机推荐

  1. IOS百度地图之--->第二篇《大头针__简单使用及自定义》

    呵呵!大家不要只看帖不回帖么,要不然我都没有积极性了. 第一步:创建一个用来呈现mapview的viewcontroller,不废话直接贴代码        BasicMapViewControlle ...

  2. DLL:无法解析的外部符号 "__declspec(dllimport)

    (4.10)碰到问题:MFC规则DLL(静态库1)中,AFX_EXT_CLASS导出类及类的对象.在静态库2中使用.出现两个问题:  (1) 静态库1中警告:dll链接不一致;  (2) 静态库2中报 ...

  3. 使用MyBatis对数据库中表实现CRUD操作(二)

    一.使用MyBatis对表实现CRUD操作 1.定义sql映射 userMapper.xml <?xml version="1.0" encoding="UTF-8 ...

  4. JS——控制标记的样式

    1.定义一个div,宽度为100px,高度为100px,背景色为粉色. 定义一个事件,鼠标移入时背景色变为蓝色,宽度变为200px. 定义一个事件,鼠标移出时背景色变为红色. html文件: < ...

  5. 光环国际PRINCE2培训费是多少?

    光环国际学习PRINCE2新活动 第一重好礼:获得商务背包一个 第二重好礼:获得600元学习代金券一张 第三重好礼:获得高清流程图一张 活动时间:2017年3月20日-3月31日 PRINCE2 (P ...

  6. 老李分享:接电话扩展之uiautomator 2

    主要的类就是上面的PhoneReceiver广播接收者.来电的时候,我们记录下电话号码,等该来电挂断以后,立即回拨给对方.配置文件如下: <?xml version="1.0" ...

  7. JSP的学习

    JSP的学习 1. (1).服务器的名字:Tomcat (2).服务器浏览器访问的地址为: http://localhost:8080 http://127.0.0.1:8080 2.简单的知识 (1 ...

  8. 项目在App Store的展示信息

    一.首部1.图标作用:一个软件的logo.修改:每次提交新版本时可以修改.要求:1>1024*1024像素 2>72dpi.RGB.平展.不透明.没有圆角 3>高品质的JPEG或PN ...

  9. Invalid command 'RailsBaseURI'

    官方指导 http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_on_Ubuntu_step_by_step   解决使 ...

  10. ajax大洋第一步

    Ajax工具包 Ajax并不是一项新技术,它实际上是几种技术,每种技术各尽其职,以一种全新的方式聚合在一起. 服务器端语言:服务器需要具备向浏览器发送特定信息的能力.Ajax与服务器端语言无关. XM ...