POJ -1066—Treasure Hunt

从零到一:RagFlow源码架构深度解析与二次开发实战指南 本文深入解析RagFlow源码架构,提供从环境搭建到二次开发的全流程实战指南。作为企业级AI搜索框架,RagFlow通过模块化设计和多模态处理能力,支持自定义智能体开发与文搜文档功能,帮助开发者高效构建智能搜索系统。 阅读详情

Treasure Hunt

Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 8367 Accepted: 3463

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 able to determine that the lower floor of the pyramid is constructed from a series of straightline walls, which intersect to form numerous enclosed chambers. Currently, no doors exist to allow access to any chamber. This state-of-the-art technology has also pinpointed the location of the treasure room. What these dedicated (and greedy) archeologists want to do is blast doors through the walls to get to the treasure room. However, to minimize the damage to the artwork in the intervening chambers (and stay under their government grant for dynamite) they want to blast through the minimum number of doors. For structural integrity purposes, doors should only be blasted at the midpoint of the wall of the room being entered. You are to write a program which determines this minimum number of doors. 
An example is shown below: 

Input

The input will consist of one case. The first line will be an integer n (0 <= n <= 30) specifying number of interior walls, followed by n lines containing integer endpoints of each wall x1 y1 x2 y2 . The 4 enclosing walls of the pyramid have fixed endpoints at (0,0); (0,100); (100,100) and (100,0) and are not included in the list of walls. The interior walls always span from one exterior wall to another exterior wall and are arranged such that no more than two walls intersect at any point. You may assume that no two given walls coincide. After the listing of the interior walls there will be one final line containing the floating point coordinates of the treasure in the treasure room (guaranteed not to lie on a wall).

Output

Print a single line listing the minimum number of doors which need to be created, in the format shown below.

Sample Input

7 
20 0 37 100 
40 0 76 100 
85 0 0 75 
100 90 0 90 
0 71 100 61 
0 14 100 38 
100 47 47 100 
54.5 55.4 

Sample Output

Number of doors = 2 

Source

East Central North America 1999

题目大意:大意:给你一个房间,房间内有很多墙,再给你个宝藏的坐标,你将使用炸药从外面砸墙而入
问:你炸墙进去通过的最少的墙的1数目是多少

思路:枚举每个端点(加上四个角)与宝藏形成的线段会和那几条线段相交,取交点最少的。

PS:题上说的是各个墙的中点,但是要枚举端点,不要枚举线段的中点,例如这种情况:

判断中点是肯定不对的,我只需要1次就好,为啥还要炸两次??

所以还是要枚举端点

代码:

/*
大意:给你一个房间,房间内有很多墙,再给你个宝藏的坐标,你将使用炸药从外面砸墙而入
问:你炸墙进去通过的最少的墙的1数目是多少
思路:初始值为1,枚举每个端点到宝藏位置会与多少条线段相交,取最小值

*/
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define ul unsigned long long
#define bug printf("mmp\n");
#define inf 0x3f3f3f3f
#define esp 1e-4
#define mm(a,b) memset(a,b,sizeof(a))
#define T()int test,q=1,tt;scanf("%d",&test),tt=test;while(test--)
const int N=1e2+10;
const int maxn=1e6+100;
const int mod=1000000007;
struct point
{
    double x,y;
} p[N];
struct line
{
    point st,ed;
    double k,b;
} l[N];
int sign(double x)
{
    if(fabs(x)<esp)
        return 0;
    return x>0?1:-1;
}
double dis(point a,point b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double mult(point a,point b,point c)
{
    return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);
}
bool judge(line l1,line l2)
{
    int a1=sign(max(l1.st.x,l1.ed.x)-min(l2.st.x,l2.ed.x));
    int a2=sign(max(l2.st.x,l2.ed.x)-min(l1.st.x,l1.ed.x));
    int a3=sign(max(l1.st.y,l1.ed.y)-min(l2.st.y,l2.ed.y));
    int a4=sign(max(l2.st.y,l2.ed.y)-min(l1.st.y,l1.ed.y));
    int a5 = sign(mult(l1.st,l1.ed,l2.st));
    int a6 = sign(mult(l1.st,l1.ed,l2.ed));
    int a7 = sign(mult(l2.st,l2.ed,l1.st));
    int a8 = sign(mult(l2.st,l2.ed,l1.ed));
    if(a1<0||a2<0||a3<0||a4<0)
        return 0;
    if(a5*a6<0&&a7*a8<0)
        return 1;
    return 0;
}
int main()
{
    int n;
    scanf("%d",&n);
    if(n==0)
    {
        printf("Number of doors = 1\n");
        return 0;
    }
    point ba;
    int np=0;
    for(int i=0; i<n; i++)
    {
        cin>>l[i].st.x>>l[i].st.y>>l[i].ed.x>>l[i].ed.y;

        p[np].x=l[i].st.x,p[np++].y=l[i].st.y;

        p[np].x=l[i].ed.x,p[np++].y=l[i].ed.y;
    }
    p[np].x=0,p[np++].y=0;
    p[np].x=0,p[np++].y=100;
    p[np].x=100,p[np++].y=100;
    p[np].x=100,p[np++].y=0;
    line lz;
    int ans=inf;
    cin>>lz.st.x>>lz.st.y;
    ///枚举每个端点和宝藏坐标,会与多少条线段相交、
    for(int i=0; i<np; i++)
    {
        int num=1;
        lz.ed.x=p[i].x,lz.ed.y=p[i].y;
        for(int j=0; j<n; j++)
        {
            if(judge(lz,l[j]))
            {
                num++;
            }
        }
        ans=min(ans,num);
    }
    printf("Number of doors = %d\n",ans);
    return 0;
}

 

手把手教你学Simulink--基于多能源系统协同控制的复杂场景实例:氢燃料电池+锂电池混合动力电动汽车能量管理仿真 本文介绍了基于Simulink的氢燃料电池与锂电池混合动力电动汽车能量管理系统的建模与仿真方法。系统包含驾驶循环输入、燃料电池子系统、锂电池子系统、能量管理、电机驱动等模块,通过协同控制优化能源分配。详细说明了从模型创建到各子系统设置的7个步骤,并提供了MATLAB代码示例。该仿真可评估不同工况下的系统响应速度、能量利用效率和电池寿命等性能指标,为混合动力汽车的能量管理策略设计和优化提供参考。 阅读详情

相关推荐

NVIDIA NCCL 安装和测试实战教程

ibrary)是用于深度学习应用的高性能通信库,可加速多GPU通信和同步。它能够在多个GPU之间进行高效的数据传输和集体操作,显著提高了分布式GPU系统上深度学习训练和推理的性能。NVIDIA NCCL是加速多GPU系统上深度学习应用的必不可少的工具。其高效的通信原语和集体操作显著提高了分布式训练和推理的性能,使其成为现代深度学习基础架构的关键组成部分。

weixin_39818775的博客 4448

Treasure Hunt--POJ 1066

1、题目类型:计算几何、线段相交。 2、解题思路:分析,读题后第一想法是从treasure点多边形向外做BFS直到到达边界,但区域内的各个不规则多边形无法确定;后发现只要在区域的四周的焦点间中点做与treasure点的线段,获取其最小焦点就可(即使线段通过内部线段的交点此时不影响结果,同样计算了两次)。步骤,(1)对区域四个边界上的点进行排序(源码的方法比较呆板、代码比较冗余,应该有更好的方法)...

weixin_34319111的博客 182

HTB Attacking GraphQL Skills Assessment

通过枚举应用,利用GraphQL API,发现sql注入点,然后利用找到flag。

qq_33522010的博客 461

POJ 1066 Treasure Hunt

POJ 1066 Treasure Hunt 这道题差点让我崩溃,排序排了一下午,崩溃的精度问题,查错查了一晚上,最后发现把Y写成X了,更悲剧,最后终于弄出来了,一定要和大家分享一下~~~~~~ 有好的意见,一定要留言呀! 链接:http://poj.org/probl

CandyLien 1115

Apple CarPlay Certification Guide December 2022 解析V1.0

Apple CarPlay Certification Guide December 2022更新说明

m0_74450450的博客 719

从CPRI到eCPRI:手把手教你用Wireshark分析基站前传协议帧结构

本文手把手教你使用Wireshark工具,深入解析从CPRI到eCPRI的基站前传协议帧结构。通过搭建分析环境、编写解析脚本,并对比两者在时延管理、帧格式及数据封装上的差异,为无线通信领域的研发与测试人员提供了一套实用的逆向分析与故障排查方法。

x8y9z0的博客 611

[poj 1066][洛谷 UVA754] Treasure Hunt {判断两条线段是否相交}

题目 https://www.luogu.org/problemnew/show/UVA754 解题思路 代码 #include&amp;amp;amp;lt;cstdio&amp;amp;amp;gt; #define db double using namespace std; const int maxn=50; const int Inf=0x3f3f3f3f; const db Err=1e-8; inline int ...

Nowed 602

【已解决】App unavailable Unfortunately, Claude is only available in certain countries and regions

App unavailable Unfortunately, Claude is only available in certain countries and regions right now. We will soon publish a list of supported locations on our website.

weixin_43941438的博客 3万+

poj1066--Treasure Hunt(规范相交)

题目链接:点击打开链接 题目大意:一个正方形的墓葬内有n堵墙,每堵墙的两个顶点都在正方形的边界上,现在这些墙将墓葬分割成了很多小空间,已知正方形内的一个点上存在宝藏,现在我们要在正方形的外面去得到宝藏,对于每个小空间,我们可以炸开它的任意一条边的中点,现在给出每堵墙的两个节点的坐标和宝藏的坐标,问如果要得到宝藏,需要炸的墙数最少是多少。 枚举正方形边界上的点作为进入正方形的节点,由这个点向宝藏

随风的专栏 1667

【论文阅读】LIME:Low-light Image Enhancement via Illumination Map Estimation(笔记最全篇)

文章目录AbstractIntroductionContributionMethodSpeed-up Method(1):ALM子问题 T子问题 G子问题 Z和μ\muμSpeed-up Method(2):权重变量实验conclusion 今天要整理的一篇论文是使用传统的方法解决低照度的问题,Guo等人于2016年发表在IEEE上,论文《LIME:Low-light Image Enhance...

florrie 2万+

MWORKS 2025a电气模型库实战:手把手教你搭建全桥LLC电路(附避坑指南)

本文详细介绍了如何使用MWORKS 2025a电气模型库搭建全桥LLC电路,包括环境准备、电路拓扑构建、参数优化及故障诊断。通过实战案例和避坑指南,帮助电源工程师高效设计谐振转换器,提升转换效率至98%以上。文章特别强调了Modelica模型库在电气系统建模中的关键作用。

s8t9u0v1w的博客 611

POJ066 Treasure Hunt(计算几何)

Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7387   Accepted: 3046 Description Archeologists from the Antiquities and Curios Museum (ACM) ha

say_c_box的博客 694

利用Sigrity的SPEED2000进行时域电源噪声分析

SPEED2000进行时域电源噪声分析

ZHENGSA的博客 3635

Treasure Hunt POJ - 1066

Treasure Hunt POJ - 1066 分类:计算几何+线段相交 题目: 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 ...

DeathYmz的博客 690

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

poj 1066 Treasure Hunt

刚开始没有考虑四顶点和各端点的区别,wa了 这次把一些基本函数自己研究透原理了,手打了一遍 /*该题中这种直接由直接构成的多边形一定是凸多边形 因为该题中的线段都是跨越整个正方形的,所以如果从目标点连一条射线出去 ,那么从其他地方绕路过去也必然会经过该线段 本来需要枚举每边界上相邻两点的中点的,但从中点穿过也相当于从端点穿过,所以直接枚举端点就可以了 */ #include #includ

lj94093的专栏 447

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

poj 1066 Treasure Hunt (线段交)

http://poj.org/problem?id=1066 题意:给出一个100*100的正方形区域,通过若干连接区域边界的线段将正方形区域分割为多个不规则多边形小区域,然后给出宝藏位置,要求从区域外部开辟到宝藏所在位置的一条路径,使得开辟路径所需要打通的墙壁数最少("打通一堵墙"即在墙壁所在线段中间位置开一空间以连通外界),输出应打通墙壁的个数(包括边界上墙壁)。 思路:用结构

大太阳 1650

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

POJ 1066 Treasure Hunt 解题报告

这道题的大概意思就是在一座金字塔的底部,有一个宝藏,但是底部这一层里面有很多纵横交错的墙,而宝藏就在其中一个由这些墙构成的房间里面。每面墙的两头都在金字塔最外面的四周的墙上。然后需要在每面墙的中间开一道门,问最少开几道门就能进到有宝藏的那个房间。 如图: 其实我们不用枚举四周墙的中点,枚举每一面墙的端点就行了。判断这个端点和宝藏构成的直线与里面的直线(墙)有多少个交点就行了。而且只需要判断

sillyhair的博客 352

POJ1066-Treasure Hunt

Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5407   Accepted: 2232 Description Archeologists from the Antiquities and Curios Museum (ACM) have

ecjtu_acm_菜鸟—鱼尾尾 900

POJ1066Treasure Hunt【判断直线相交】

Language:Default Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5942   Accepted: 2466 Description Archeologists from

走一步再走一步 1619

POJ - 1066 Treasure Hunt(线段相交)

链接:https://cn.vjudge.net/problem/POJ-1066 题意:100*100的矩形内有n条线段,给出一个点,问从矩形外面到该点最少要穿过几条线段?也就是从该点引一条向外的射线,最少与几条线段相交? 思路:这条射线肯定过这n条线段的一个端点,枚举判断即可。 #include <cstdio> #include <iostream> #inc...

birdmanqin的博客 234

POJ 1066 Treasure Hunt

题意:  线段与线段相交会形成密室, 求边界上到宝藏所经过的最少线段数N , 则答案就是N+1              思路: 暴力枚举,我们知道, 起点一定是边界上某一点,而终点一定是宝藏。              因为有 doors should only be blasted at the midpoint of the wall of the room being ent

u013570474的专栏 359
上一篇: POJ 1556-The Doors
下一篇: ZOJ-3203 Light Bulb
lee371042
博客等级 码龄9年 133粉丝 227原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值