POJ 3168 Barn Expansion (几何基础)】的更多相关文章

题目链接:id=3168">POJ 3168 Barn Expansion 题意:抽象出来就是给出n个矩形的坐标是(左下角和右上角的坐标,矩形的边都是平行x,y轴),问有几个矩形和其它矩形没有接触(仅仅存在边接触或者点接触,不存在有公共面积). 思路:把边分成两类,平行x轴和平行y轴.对边进行排序.然后for一遍推断是否有相交就可以 AC代码: #include <stdio.h> #include <vector> #include <map> #in…
题链:http://poj.org/problem? id=3168 Barn Expansion Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2087   Accepted: 544 Description Farmer John has N (1 <= N <= 25,000) rectangular barns on his farm, all with sides parallel to the X and…
Barn Expansion Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2465   Accepted: 666 Description Farmer John has N (1 <= N <= 25,000) rectangular barns on his farm, all with sides parallel to the X and Y axes and integer corner coordinat…
[题目链接] http://poj.org/problem?id=3168 [题目大意] 给出一些矩形,没有相交和包含的情况,只有相切的情况 问有多少个矩形没有相切或者边角重叠 [题解] 我们将所有的与x轴平行的线段和与y周平行的线段分开处理,判断是否出现重合 对重合的两个矩形进行标识,最后没有被标识过的矩形数目就是答案. [代码] #include <cstdio> #include <vector> #include <algorithm> #include <…
Farmer John has N (1 <= N <= 25,000) rectangular barns on his farm, all with sides parallel to the X and Y axes and integer corner coordinates in the range 0..1,000,000. These barns do not overlap although they may share corners and/or sides with ot…
题目链接:http://poj.org/problem?id=2318 Time Limit: 2000MS Memory Limit: 65536K 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 when he is fin…
Pipe Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9932   Accepted: 3045 Description The GX Light Pipeline Company started to prepare bent pipes for the new transgalactic light pipeline. During the design phase of the new pipe shape th…
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 in…
题意: 思路: 我们可以把每个矩形拆成四条线 与x轴平行的放在一起 与y轴平行的放在一起 排个序 判一判有没有交 有交 则说明不可扩张 统计一下 就可以了 处理的姿势很重要 姿势不对毁一生 //By SiriusRen #include <cstdio> #include <algorithm> using namespace std; #define N 55555 int n,x1,y1,x2,y2,cnt,vis[N],ans,maxx; struct Edgex{int x…
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem 10983 18765 Y 1036 [ZJOI2008]树的统计Count 5293 13132 Y 1588 [HNOI2002]营业额统计 5056 13607 1001 [BeiJing2006]狼抓兔子 4526 18386 Y 2002 [Hnoi2010]Bounce 弹飞绵羊 43…
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY…
bzoj上的usaco题目还是很好的(我被虐的很惨. 有必要总结整理一下. 1592: [Usaco2008 Feb]Making the Grade 路面修整 一开始没有想到离散化.然后离散化之后就很好做了.F[I,j]表示第i个点,高度>=j或<=j,f[I,j]=min(f[i-1,j]+abs(b[j]-a[i]),f[I,j-1]) 1593: [Usaco2008 Feb]Hotel 旅馆 线段树 ★1594: [Usaco2008 Jan]猜数游戏 二分答案然后写线段树维护 15…
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116…
http://poj.org/problem?id=1556 首先路径的每条线段一定是端点之间的连线.证明?这是个坑...反正我是随便画了一下图然后就写了.. 然后re是什么节奏?我记得我开够了啊...然后再开大点才a...好囧啊. #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <alg…
http://poj.org/problem?id=2318 第一次完全是$O(n^2)$的暴力为什么被卡了-QAQ(一定是常数太大了...) 后来排序了下点然后单调搞了搞..(然而还是可以随便造出让我的code变成$O(n^2)$的23333) #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include…
http://poj.org/problem?id=2653 我很好奇为什么这样$O(n^2)$的暴力能过.... 虽然说这是加了链表优化的,但是最坏不也是$O(n^2)$吗...(只能说数据太弱...) 然后本题裸的判线段相交和点在直线上...(看了网上的标程,不判端点的情况都能过我也是醉了...) #include <cstdio> #include <cstring> #include <cmath> #include <string> #includ…
http://poj.org/problem?id=1269 我会说这种水题我手推公式+码代码用了1.5h? 还好新的一年里1A了---- #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <algorithm> #include <queue> #include <…
由乘2取整得到分数的小数位,可以找到规律!!! 例如:1/10,2/10,4/10,8/10,16/10,32/10,64/10…… 取整后:1/10,2/10,4/10,8/10,6/10,2/10,4/10…… 这样我们就发现规律了!!! 也就是对于p/q而言,要满足2^x=2^y mod q (gcd(p,q)==1); 化简:2^x*(2^(x-y)-1) = 0 mod q; q里面2的倍数有多少个,就是最小的循环起始位置. 继而化简:2^(x-y) = 1 mod q' (q'除以2…
题目链接: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…
poj 1696 Space Ant 链接:http://poj.org/problem?id=1696 题意:在坐标轴上,给定n个点的 id 以及点的坐标(xi, yi),让你以最底端点开始,从右依次找出最外围的的点,形成一个螺旋状的图像.图形见题目例题,输出他们的 id. 思路:先找出最下面的点,然后依次为“据点”,对其他点进行极角排序,取出第一个点,以此点为“据点”,对其他未选择的点极角排序,选出排序后第一个点,……, 依此类推,取得 n 个点.复杂度(n^2*log(n)). 代码: #…
[题目链接] http://poj.org/problem?id=3293 [题目大意] 给出一些点,每个点只能向外引出一条平行X轴,和Y轴的边, 问能否构成一个闭多边形,如果能,返回多边形的总边长,否则返回-1 [题解] 我们发现对于每一行或者每一列都必须有偶数个点,且两两之间相邻才能满足条件 所以我们将其连线之后判断是否可以构成一个封闭图形,同时还需要判断这些线是否会相交, 如果相交即不成立 [代码] #include <cstdio> #include <algorithm>…
  Segments Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11593   Accepted: 3657 Description Given n segments in the two dimensional space, write a program, which determines if there exists a line such that after projecting these segmen…
欧拉定理.根据分数转换成2进制的过程,分子每次都乘2.对于循环节x,当2^x = 1(mod b)时肯定是循环节.显然当分母不能整除2的时候,即分母和2互质的话,就可以利用欧拉定理,使得2^(Euler(b)) = 1(mod b).然后对于Euler(b),枚举其因子,找到最小循环节就可以了. #include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include…
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const int maxn=1e4+9; int x[maxn],y[maxn]; struct D { int x,y; bool operator <(const D &xx)const { if(…
The Perfect Stall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24081   Accepted: 10695 Description Farmer John completed his new barn just last week, complete with all the latest milking technology. Unfortunately, due to engineering p…
http://poj.org/problem?id=3190 Stall Reservations Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3567   Accepted: 1276   Special Judge Description Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be m…
http://poj.org/problem?id=2376 Cleaning Shifts Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12604   Accepted: 3263 Description Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn.…
http://poj.org/problem?id=3262 Protecting the Flowers Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4930   Accepted: 1965 Description Farmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. When…
Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 22736   Accepted: 10144 Description Farmer John completed his new barn just last week, complete with all the latest milking technology. Unfortunately, due to engineering problems, all the s…
题目链接:http://poj.org/problem?id=1274 The Perfect Stall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23088   Accepted: 10285 Description Farmer John completed his new barn just last week, complete with all the latest milking technology.…