Toy Storage
题型与2318 TOYS一样,注意要对线段排序,现在模板又更新了~~
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<time.h>
using namespace std;
#define MS0(a) memset(a,0,sizeof(a))
const int MAXN = ;
struct point{
int x,y;
point(){}
point(int _x,int _y){
x = _x; y = _y;
}
long long operator *(const point &b)const{// 点向量叉乘
return (1LL*x*b.y - 1LL*y*b.x);
}
point operator -(const point &b)const{
return point(x - b.x,y - b.y);
}
long long dot(const point &b){ //点乘
return 1LL*x*b.x + 1LL*y*b.y;
}
double dist(const point &b){
return sqrt(1LL*(x-b.x)*(x-b.x)+1LL*(y-b.y)*(y-b.y));
}
long long dist2(const point &b){
return 1LL*(x-b.x)*(x-b.x)+1LL*(y-b.y)*(y-b.y);
}
double len(){
return sqrt(1LL*x*x+1LL*y*y);
}
double point_to_segment(point b,point c)//点a到“线段” bc的距离
{
point v[];
v[] = {c.x - b.x,c.y - b.y};
v[] = {x - b.x,y - b.y};
v[] = {x - c.x,y - c.y};
if(v[].dot(v[]) < ) return v[].len();
if(v[].dot(v[]) > ) return v[].len();
return fabs(.*(v[]*v[])/v[].len());
}
long long Xmult(point b,point c){ // 当a->b与a->c顺时针转时,返回正;
return (b-*this)*(c-*this);
}
bool operator <(const point &b)const{
return y < b.y||(y == b.y && x < b.x);
}
void input(){
scanf("%d%d",&x,&y);
}
}p[MAXN]; struct Line{
point s,t;
Line(){}
Line(point _s,point _t){
s = _s,t =_t;
}
bool operator <(const Line &b)const{
return s < b.s;
}
}line[MAXN]; int ans[MAXN],ret[MAXN];
int main()
{
int n,m,i,j,x1,y1,x2,y2,kase = ,U,L;
while(scanf("%d",&n),n){
MS0(ans);
MS0(ret);
scanf("%d%d%d%d%d",&m,&x1,&y1,&x2,&y2);
for(i = ;i <= n;i++){
scanf("%d%d",&U,&L);
line[i] = Line(point(U,y1),point(L,y2));
}
sort(line+,line+n+);
line[] = Line(point(x1,y1),point(x1,y2));
int x,y;
for(i = ;i < m;i++){
scanf("%d%d",&x,&y);
int l = , r = n,tmp;
while(l <= r){
int mid = l + r >> ;
if( point(x,y).Xmult(line[mid].s,line[mid].t) <= ) r = mid-; //在线的上边
else tmp = mid,l = mid+; //线下的点所在的区域才是改line的标号;
}
ret[tmp]++;
}
for(i = ;i <= n;i++){
ans[ret[i]]++;
}
puts("Box");
for(i = ;i <= m;i++)if(ans[i])
printf("%d: %d\n",i,ans[i]);
}
return ;
}
Toy Storage的更多相关文章
- POJ 2398 - Toy Storage 点与直线位置关系
Toy Storage Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5439 Accepted: 3234 Descr ...
- POJ 2398 Toy Storage(计算几何,叉积判断点和线段的关系)
Toy Storage Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3146 Accepted: 1798 Descr ...
- POJ 2318 TOYS && POJ 2398 Toy Storage(几何)
2318 TOYS 2398 Toy Storage 题意 : 给你n块板的坐标,m个玩具的具体坐标,2318中板是有序的,而2398无序需要自己排序,2318要求输出的是每个区间内的玩具数,而231 ...
- 2018.07.04 POJ 2398 Toy Storage(二分+简单计算几何)
Toy Storage Time Limit: 1000MS Memory Limit: 65536K Description Mom and dad have a problem: their ch ...
- POJ 2398 Toy Storage (叉积判断点和线段的关系)
题目链接 Toy Storage Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4104 Accepted: 2433 ...
- poj 2398 Toy Storage(计算几何)
题目传送门:poj 2398 Toy Storage 题目大意:一个长方形的箱子,里面有一些隔板,每一个隔板都可以纵切这个箱子.隔板将这个箱子分成了一些隔间.向其中扔一些玩具,每个玩具有一个坐标,求有 ...
- poj2398 Toy Storage 计算几何,叉积,二分
poj2398 Toy Storage 链接 poj 题目大意 这道题的大概意思是先输入6个数字:n,m,x1,y1,x2,y2.n代表卡片的数量,卡片竖直(或倾斜)放置在盒内,可把盒子分为n+1块区 ...
- poj 2398 Toy Storage(计算几何 点线关系)
Toy Storage Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4588 Accepted: 2718 Descr ...
- POJ 2398 Toy Storage(计算几何)
题意:给定一个如上的长方形箱子,中间有n条线段,将其分为n+1个区域,给定m个玩具的坐标,统计每个区域中的玩具个数. 题解:通过斜率判断一个点是否在两条线段之间. /** 通过斜率比较点是否在两线段之 ...
随机推荐
- Java解惑五:类之谜
本文是依据JAVA解惑这本书,做的笔记.电子书见:http://download.csdn.net/detail/u010378705/7527721 谜题46 函数重载的问题. JAVA重载解析过程 ...
- sigar监控
相关参照博客: http://liningjustsoso.iteye.com/blog/1254584 http://blog.csdn.net/aoxida/article/category/12 ...
- Xcode 4-PBXcp error修复-No such file or directory
Xcode 4-PBXcp error修复-No such file or directory (2013-05-02 15:20:50) 转载▼ 标签: apple iphone ios 移动开发 ...
- NotificationListenerService不能监听到通知
作者:Hugo链接:https://www.zhihu.com/question/33540416/answer/113706620来源:知乎著作权归作者所有,转载请联系作者获得授权. 背景知识: 所 ...
- Java基础知识强化之IO流笔记38:字符流缓冲流之BufferedWriter / BufferedReader使用
1. 字符流缓冲流: 字符流为了高效读写,也提供了对应的字符缓冲流. BufferedWriter:字符缓冲输出流 BufferedReader:字符缓冲输入流 2. BufferedWriter使用 ...
- Java基础知识强化之集合框架笔记65:Map集合之集合多层嵌套的数据分析
1. 为了更符合要求: 这次的数据就看成是学生对象. 传智播客 bj 北京校区 jc 基础班 林青霞 27 风清扬 30 jy 就业班 赵雅芝 28 武鑫 29 sh 上海 ...
- Android(java)学习笔记140:SpannableString类的使用
我们之前说过了我们想实现在TextView组件之中,可以显示URL.Email等特殊信息,这些信息点击可以实现跳转,真正意义上的超链接 要实现上面的需求就要SpannableString这个类. 因为 ...
- 多版本uboot命令行分析
1.1.6 经典版本: 1.uboot第二阶段第一个函数void start_armboot (void),一路gd参数设置.设备初始化.控制台初始化.端口初始化,最后到main_loop ()命令行 ...
- 第二种方式读取并显示HDFS中的内容
1.讀取HDFS内容的java客戶端代碼: package Hdfs; import java.io.InputStream; import java.net.URI; import org.apac ...
- webstom 配置git 后左侧菜单栏配色调整
ws配置了git进行版本管理,但是最近改了主题,发现左侧列表的文件名的颜色都是一个颜色了.我想要的是,对未提交的文件用颜色区分,新建的,修改的,冲突的分别设置不同的颜色,不知在哪里能设置,求助 老规矩 ...