题目链接:http://poj.org/problem?id=2398

思路RT,和POJ2318一样,就是需要排序,输出也不一样。手工画一下就明白了。注意叉乘的时候a×b是判断a在b的顺时针还是逆时针侧,>0是顺时针测,<0是逆时针侧,本题对应看成右、左侧,特别注意。

 /*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define fr first
#define sc second
#define cl clear
#define BUG puts("here!!!")
#define W(a) while(a--)
#define pb(a) push_back(a)
#define Rint(a) scanf("%d", &a)
#define Rll(a) scanf("%lld", &a)
#define Rs(a) scanf("%s", a)
#define Cin(a) cin >> a
#define FRead() freopen("in", "r", stdin)
#define FWrite() freopen("out", "w", stdout)
#define Rep(i, len) for(int i = 0; i < (len); i++)
#define For(i, a, len) for(int i = (a); i < (len); i++)
#define Cls(a) memset((a), 0, sizeof(a))
#define Clr(a, x) memset((a), (x), sizeof(a))
#define Full(a) memset((a), 0x7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
#define lowbit(x) x & (-x)
#define onenum(x) __builtin_popcount(x)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef map<string, int> msi;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; typedef struct Point {
int x, y;
Point() {}
Point(int xx, int yy) : x(xx), y(yy) {}
bool operator==(Point p) {
return x == p.x && y == p.y;
}
bool operator<(Point p) {
if(x == p.x) return y < p.y;
return x < p.x;
}
}Point;
typedef struct Line {
Point a, b;
Line() {}
Line(Point aa, Point bb) : a(aa), b(bb) {}
}Line;
const int maxn = ;
const int maxm = ;
Line line[maxn];
Point s, e;
int n, m;
int tmp[maxm];
int ans[maxm]; int ok(Point p, Line l) {
RT ((l.b.y-l.a.y)*(p.x-l.a.x)-(p.y-l.a.y)*(l.b.x-l.a.x));
} bool cmp(Line a, Line b) {
if(a.a == b.a) return a.b < b.b;
return a.a < b.a;
} int main() {
// FRead();
int x1, x2;
bool flag = ;
while(~Rint(n) && n) {
Cls(tmp); Cls(ans);
Rint(m); Rint(s.x); Rint(s.y); Rint(e.x); Rint(e.y);
Rep(i, n) {
Rint(x1); Rint(x2);
line[i] = Line(Point(x1, s.y), Point(x2, e.y));
}
line[n] = Line(Point(e.x, s.y), e);
Point p;
sort(line, line+n+, cmp);
W(m) {
Rint(p.x); Rint(p.y);
int l = , r = n;
int ret;
while(l <= r) {
int m = (l + r) >> ;
if(ok(p, line[m]) > ) {
ret = m;
r = m - ;
}
else l = m + ;
}
tmp[ret]++;
}
int hi = ;
Rep(i, n+) {
hi = max(hi, tmp[i]);
ans[tmp[i]]++;
}
printf("Box\n");
For(i, , hi+) {
if(ans[i]) printf("%d: %d\n", i, ans[i]);
}
}
RT ;
}

[POJ2398]Toy Storage(计算几何,二分,判断点在线段的哪一侧)的更多相关文章

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

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

  2. 2018.07.04 POJ 2398 Toy Storage(二分+简单计算几何)

    Toy Storage Time Limit: 1000MS Memory Limit: 65536K Description Mom and dad have a problem: their ch ...

  3. POJ 2398 Toy Storage (叉积判断点和线段的关系)

    题目链接 Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4104   Accepted: 2433 ...

  4. poj 2398 Toy Storage(计算几何)

    题目传送门:poj 2398 Toy Storage 题目大意:一个长方形的箱子,里面有一些隔板,每一个隔板都可以纵切这个箱子.隔板将这个箱子分成了一些隔间.向其中扔一些玩具,每个玩具有一个坐标,求有 ...

  5. poj 2398 Toy Storage(计算几何 点线关系)

    Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4588   Accepted: 2718 Descr ...

  6. poj 2398(叉积判断点在线段的哪一侧)

    Toy Storage Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5016   Accepted: 2978 Descr ...

  7. POJ 2398 Toy Storage(计算几何)

    题意:给定一个如上的长方形箱子,中间有n条线段,将其分为n+1个区域,给定m个玩具的坐标,统计每个区域中的玩具个数. 题解:通过斜率判断一个点是否在两条线段之间. /** 通过斜率比较点是否在两线段之 ...

  8. poj 2398 Toy Storage【二分+叉积】

    二分点所在区域,叉积判断左右 #include<iostream> #include<cstdio> #include<cstring> #include<a ...

  9. [poj2398]Toy Storage

    接替关键:和上题类似,输出不同,注意输入这道题需要排序. #include<cstdio> #include<cstring> #include<algorithm> ...

随机推荐

  1. hash --C++

    题目来源:code[VS] 这是一个极其无聊的hash题.... 1230 元素查找 题目描述 Description 给出n个正整数,然后有m个询问,每个询问一个整数,询问该整数是否在n个正整数中出 ...

  2. HTML & XML 转义字符

    HTML & XML 转义字符 HTML中<, >,&等有特殊含义,(前两个字符用于链接签,&用于转义),不能直接使用.使用这三个字符时,应使用它们的转义序列,如下 ...

  3. C# ASP.NET系统缓存全解析

    原文:http://blog.csdn.net/wyxhd2008/article/details/8076105 目录(?)[-] 系统缓存的概述 页面输出缓存 页面局部缓存 文件缓存依赖 数据库缓 ...

  4. WinForm程序界面假死,寻求完美解决方案

    故事的开端是这样的,小白是一个程序员,他确实也是一个小白,目前还在程序员发展的道路上,兢兢业业的小心求学. 有一天,小白接到一个任务,完成一个Winform程序,附加一个功能就是可以读IC卡. 小白终 ...

  5. Jenkins部署.NET网站项目

    Jenkins Jenkins是一个开源软件项目,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能. Jenkins是基于Java开发的一种持续集成工具,用于监控持续重复的工作,功能包括: 持 ...

  6. Query classification; understanding user intent

    http://vervedevelopments.com/Blog/query-classification-understanding-user-intent.html What exactly i ...

  7. 3640: JC的小苹果 - BZOJ

    让我们继续JC和DZY的故事.“你是我的小丫小苹果,怎么爱你都不嫌多!”“点亮我生命的火,火火火火火!”话说JC历经艰辛来到了城市B,但是由于他的疏忽DZY偷走了他的小苹果!没有小苹果怎么听歌!他发现 ...

  8. [转载]如何申请淘宝app_key、app_secret、SessionKey?

    不知道如何申请淘宝开发平台的App Key?其实申请App key很简单,主要了解申请步骤以及各个App key的数据阶段状态就可以了!下面由淘客帝国为您做详细图文讲解!申请比较简单,不过为了新手能够 ...

  9. [nowCoder] 子数组最大乘积

    给定一个double类型的数组arr,其中的元素可正可负可0,返回子数组累乘的最大乘积.例如arr=[-2.5,4,0,3,0.5,8,-1],子数组[3,0.5,8]累乘可以获得最大的乘积12,所以 ...

  10. Graham's Scan算法

    原文链接:http://www.cnblogs.com/devymex/archive/2010/08/09/1795392.html C++/STL实现: #include <algorith ...