poj1066--Treasure Hunt(规范相交)】的更多相关文章

Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4797   Accepted: 1998 Description Archeologists from the Antiquities and Curios Museum (ACM) have flown to Egypt to examine the great pyramid of Key-Ops. Using state-of-the-ar…
Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8192   Accepted: 3376 Description Archeologists from the Antiquities and Curios Museum (ACM) have flown to Egypt to examine the great pyramid of Key-Ops. Using state-of-the-ar…
Treasure Hunt 大意:在一个矩形区域内.有n条线段,线段的端点是在矩形边上的,有一个特殊点,问从这个点到矩形边的最少经过的线段条数最少的书目,穿越仅仅能在中点穿越. 思路:须要巧妙的转换一下这个问题,由于从一个点到终点不可能"绕过"围墙.仅仅能穿过去,所以门是否开在中点是无所谓的,仅仅要求四周线段中点到终点的线段与墙的最少交点个数就可以.更进一步,实际上,仅仅需推断四周围墙的全部点与终点的连线与内墙的最少交点加一就可以. struct Point{ double x, y;…
嘟嘟嘟 题意看题中的图就行:问你从给定的点出发最少需要穿过几条线段才能从正方形中出去(边界也算). 因为\(n\)很小,可以考虑比较暴力的做法.枚举在边界中的哪一个点离开的.也就是枚举四周的点\((x, y)\),并和起点\((x_0, y_0)\)连成线段,求和多少条线段相交. 但是因为点可以是实数,所以不知道怎么枚举.不过想想就知道,同一个区间中的点是等价的.因此我们只要枚举线段的端点即可. 至于判断线段相交,用叉积实现:对于线段\(AB\)和\(CD\),如果\((\overrightar…
题目链接 题目描述 一个正方形房间被分成若干个小室,宝藏在其中某一点.现可炸开任意一堵墙壁的中点位置.问至少要炸开多少堵墙才能从外面到达宝藏所在地. 思路 (很巧妙,没想到) 直接枚举墙壁与正方形外壁的交点,与宝藏所在地连线,看连线与多少堵墙相交,即需要炸开的墙壁数目. 为什么呢?因为每堵墙的两个端点都在正方形外壁上,所以宝藏与目的地的连线所经过的墙都是无法绕过去的,必须得炸开. 注意特判没有墙的情况. Code #include <cstdio> #include <cmath>…
题目链接:http://poj.org/problem?id=1066 Time Limit: 1000MS Memory Limit: 10000K Description Archeologists from the Antiquities and Curios Museum (ACM) have flown to Egypt to examine the great pyramid of Key-Ops. Using state-of-the-art technology they are…
题目链接:点击打开链接 题目大意:一个正方形的墓葬内有n堵墙,每堵墙的两个顶点都在正方形的边界上,如今这些墙将墓葬切割成了非常多小空间,已知正方形内的一个点上存在宝藏,如今我们要在正方形的外面去得到宝藏,对于每一个小空间,我们能够炸开它的随意一条边的中点,如今给出每堵墙的两个节点的坐标和宝藏的坐标,问假设要得到宝藏,须要炸的墙数最少是多少. 枚举正方形边界上的点作为进入正方形的节点,由这个点向宝藏连出一条线段,这条线段和多少个墙相交,那么就须要炸坏多少个墙,找出一个最小的值. 原因,由于每堵墙的…
Treasure Hunt IV Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is exploring the wonderland, suddenly she fell into a hole, when she woke up, she found there are b - a + 1 treasures labled a from b in front of her.Alice was very excited but…
题目链接 题意 : 如果两个线段相交就属于同一集合,查询某条线段所属集合有多少线段,输出. 思路 : 先判断与其他线段是否相交,然后合并. #include <cstdio> #include <cstring> #include <iostream> #include <cmath> #define eps 1e-8 #define zero(x) (((x) > 0 ? (x) : (-x)) < eps) using namespace s…
Treasure Hunt IV Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is exploring the wonderland, suddenly she fell into a hole, when she woke up, she found there are b - a + 1 treasures labled a from b in front of her. Alice was very excited but…
Treasure Hunt time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Captain Bill the Hummingbird and his crew recieved an interesting challenge offer. Some stranger gave them a map, potion of tel…
H - Treasure Hunt IV Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Description Alice is exploring the wonderland, suddenly she fell into a hole, when she woke up, she found there are b - a + 1 treasures labled a from b in…
E - Treasure Hunt I Time Limit:2000MS Memory Limit:65536KB Description Akiba is a dangerous country since a bloodsucker living there. Sometimes the bloodsucker will appear and kill everyone who isn't at his hometown. One day, a brave person named CC…
题目描述 Once there was a pig, which was very fond of treasure hunting. The treasure hunt is risky, and it is inadvertently caught in the peach blossom trap. Fortunately, it has got a map of peach blossom trap. You can think of it as a matrix of R row an…
[ZOJ3626]Treasure Hunt I Time Limit: 2 Seconds      Memory Limit: 65536 KB Akiba is a dangerous country since a bloodsucker living there. Sometimes the bloodsucker will appear and kill everyone who isn't at his hometown. One day, a brave person named…
Treasure Hunt I Time Limit: 2 Seconds      Memory Limit: 65536 KB Akiba is a dangerous country since a bloodsucker living there. Sometimes the bloodsucker will appear and kill everyone who isn't at his hometown. One day, a brave person named CC finds…
A. Treasure Hunt time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Captain Bill the Hummingbird and his crew recieved an interesting challenge offer. Some stranger gave them a map, potion of…
Treasure Hunt IV Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is exploring the wonderland, suddenly she fell into a hole, when she woke up, she found there are b - a + 1 treasures labled a from b in front of her. Alice was very excited but…
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her. The three friends are very smart so they passe…
1066 -- Treasure Hunt 题意是,在一个金字塔中有一个宝藏,金字塔里面有很多的墙,要穿过墙壁才能进入到宝藏所在的地方.可是因为某些原因,只能在两个墙壁的交点连线的中点穿过墙壁.问最少要穿过多少墙壁才能得到宝藏. 比较容易想到的一个办法就是直接用中点构图,然后判断点与点之间是否能够直接相连,最后bfs得到最小距离. 我的代码也是这样做,结果相当险的900+ms通过. 代码如下: #include <cstdio> #include <cstring> #includ…
题意:给你一个100*100的正方形,再给你n条线(墙),保证线段一定在正方形内且端点在正方形边界(外墙),最后给你一个正方形内的点(保证不再墙上) 告诉你墙之间(包括外墙)围成了一些小房间,在小房间内可以从房间边界(墙)的中点走过这堵墙,问你从给定的点走到外墙外最少走过的墙数 题解:注意我们可以从每个房间的墙的中点走出,而不是一整条线段(墙)的中点走出.... 然后我们可以找四周的边界中的每个点与给定点的连线,再与给定的线段找相交最少的交点数就是答案 但是边界每个点是无穷多个,因此我们可以这样…
思路:枚举四边墙的门的中点,与终点连成一条线段,判断与其相交的线段的个数.最小的加一即为答案. 我是傻逼,一个数组越界调了两个小时. #include<stdio.h> #include<string.h> #include<math.h> #include<iostream> using namespace std; ; ; int sgn(double x){ ; ) ; ; } struct point{ double x,y; point(){} p…
题目传送门 题意:从四面任意点出发,有若干障碍门,问最少要轰掉几扇门才能到达终点 分析:枚举入口点,也就是线段的两个端点,然后选取与其他线段相交点数最少的 + 1就是答案.特判一下n == 0的时候 /************************************************ * Author :Running_Time * Created Time :2015/10/26 星期一 16:30:26 * File Name :POJ_1066.cpp ***********…
http://poj.org/problem?id=1066 题目大意:给一个由墙围成的正方形,里面有若干墙,每次破墙只能从(当前看到的)墙的中点破,求最少破多少墙才能看到宝藏. —————————————————————— 显然枚举起点然后画一条以终点为端点的线,求线和多少墙相交即可. 但是我不会证明:这里有证明:https://www.cnblogs.com/anrainie/p/4049844.html 然后有该证明我们得到只要起点为这些线的端点即可. #include<cstdio>…
原题 在金字塔内有一个宝藏p(x,y),现在要取出这个宝藏. 在金字塔内有许多墙,为了进入宝藏所在的房间必须把墙炸开,但是炸墙只能炸每个房间墙的中点. 求将宝藏运出城堡所需要的最小炸墙数. 判断点和直线相交. 枚举每道墙的两个端点和p的连线这条线段和墙的交点的次数最小值即为需要炸墙的最小次数. [注意当墙数为零时输出1:] #include<cstdio> #include<algorithm> #define N 33 using namespace std; int ans=0…
题意: 正方形的房子,给一些墙,墙在区域内是封闭的,给你人的坐标,每穿过一道墙需要一把钥匙,问走出正方形需要多少把钥匙. 解法: 因为墙是封闭的,所以绕路也不会减少通过的墙的个数,还不如不绕路走直线,所以枚举角度,得出直线,求出与正方形内的所有墙交点最少的值,最后加1(正方形边界). 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include…
题目大意:在一个正方形的迷宫里有一些交错墙,墙的两端都在迷宫的边缘墙上面,现在得知迷宫的某个位置有一个宝藏,所以需要砸开墙来获取宝藏(只能砸一段墙的中点),问最少要砸开几面墙.   分析:这个题意刚开始理解错了,以为只能砸整面墙的中点,而实际上使一段墙的中点,也就是两个交点之间的墙,这样问题就变得比较容易了,中点的意义也就不存在了,因为所有的墙都是连接的边缘,所以如果从起点到终点连线有这堵墙,那么这堵墙一定无法绕过去,所以枚举所有的边缘点到终点有几面墙即可,注意不管怎样,边缘墙一定是要砸的.  …
题意:给出一个100*100的正方形区域,通过若干连接区域边界的线段将正方形区域分割为多个不规则多边形小区域,然后给出宝藏位置,要求从区域外部开辟到宝藏所在位置的一条路径,使得开辟路径所需要打通的墙壁数最少("打通一堵墙"即在墙壁所在线段中间位置开一空间以连通外界),输出应打通墙壁的个数(包括边界上墙壁).题解:枚举每一个入口,在所有的情况中取穿墙数最少的输出即可,枚举每一个入口的时候,并不用枚举每条边的中间点,直接枚举该线段的两个顶点就行(因为要经过一个墙,那么从线段的任意地方进去都…
题目描述 Once there was a pig, which was very fond of treasure hunting. One day, when it woke up, it found itself in a strange land of treasure. As for how to come in, or how to go out, no ways to know. Sad. The good news is, it was lucky that it got the…
题面 题意:给你一个20*20的地图,起点(0,0),终点(n-1,n-1),有障碍的点为‘#’,每次可以向8个方向走一步,还给了一个三角形,除了障碍以外,到这8个方向上的点的线段如果没有与三角形相交,那么就可以到达,问最少步数 题解:主要是判断线段与三角形的相交,去年在现场和大多题解都是慢慢讨论,因为这个线段其实可以在边上,可以与三角形有交点, 今天重现才想到,只需要线段上有一点在三角形内部就不能走,坐标范围不大,直接枚举线段上200个点,挨着判断就行 在判断点在三角形内部时,注意顺时针逆时针…