poj2318】的更多相关文章

TOYS Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14433   Accepted: 6998 Description Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem - their child John never puts his toys away w…
题目:http://poj.org/problem?id=2318 题意: 给定一个如上的长方形箱子,中间有n条线段,将其分为n+1个区域,给定m个玩具的坐标,统计每个区域中的玩具个数.(其中这些线段有序且不相交) 解答: 因为线段是有序给出,所以不用排序,判断某个点在哪个区域,采用二分法,将某个点和线段的叉积来判断这个点是在线的左边或者右边,根据这个来二分找出区域. 这是第一道计算几何的题目,怎么说呢,对于二分的边界问题还有点搞不清楚,这次是对线段二分,感觉二分真的很有用处. 开阔思维!!!具…
题目链接:https://cn.vjudge.net/problem/POJ-2318 题意 在一个矩形内,给出n-1条线段,把矩形分成n快四边形 问某些点在那个四边形内 思路 二分+判断点与位置关系 提交过程 WA*n x1和x2,y1和y2在复制的时候没分清(哭 WA 可能存在二分问题? AC 代码 #define PI 3.1415926 #include <cmath> #include <cstdio> #include <vector> #include &…
题目链接:https://vjudge.net/problem/POJ-2318 题意:有n条线将矩形分成n+1块,m个点落在矩形内,求每一块点的个数. 思路: 最近开始肝计算几何,之前的几何题基本处于挂机状态,但听别人说几何题不会太难,所以打算把几何给过了. 先引入叉积的一个重要性质,O为原点: OP^OQ>0 : P在Q的顺时针方向. OP^OQ<0 : P在Q的逆时针方向. OP^OQ=0 : O,P,Q共线. 那么我们就可以利用该性质判断一个点P在直线AB的左侧当且仅当:PA^PB&l…
题意:把一个矩形划分成n部分,再给出一堆点,求每个部分内落入了多少点 sol attempt1:暴力 注意每个polygon中的点要按笔画的顺序排列好.还有就是有的点可能落在了upper or lower edge,稍微处理一下(ans==1 or 2都算) TLE了 -_-|| #include<vector> #include<list> #include<map> #include<set> #include<deque> #include…
题目链接:http://poj.org/problem?id=2318 #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #include<queue> using namespace std; ; ; const int INF = 0x3f3f3f; ; const double PI = acos(-…
Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem - their child John never puts his toys away when he is finished playing with them. They gave John a rectangular box to put his toys in, but John i…
题目大意:给定一个矩形和一些线段,线段将矩形分割为从左至右的若干部分,之后给出一些玩具的坐标,求每个部分中玩具的数量 #include<cstdio> #include<cstdlib> #include<cstring> using namespace std; struct point { int x, y; }; struct Node { point a, b; }A[5010]; int pos[5010]; bool is_right(int xx, int…
TOYS Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 16222   Accepted: 7779 Description Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem - their child John never puts his toys away w…
题目链接:http://poj.org/problem?id=2398 Time Limit: 1000MS Memory Limit: 65536K Description 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…