USACO section 3.4 Closed Fences(计算几何+叉积+二分)

clockwise-clockware 顺时针时钟 该项目包含一个用于在线接收订单的Web应用程序。 入门 要启动该项目,您将需要npm。 您可以在此处找到有关安装npm的说明: ://www.npmjs.com/get-npm 另外,您将需要MySQL CLI。 打开它并创建数据库测试,并授予用户“ admin”的权限: create database test ; grant all on test. * to ' admin ' @ ' localhost ' identified by ' passwordsecret ' ; 打开项目文件夹,找到文件example.env,将其重命名为.env,然后输入所有必需的参数。 然后运行您的CLI, cd到您的项目文件夹并使用命令: $ git clone git@github.com:kkdshka/clockwise-clockware.git $ cd cl 立即下载

Closed Fences

A closed fence in the plane is a set of non-crossing, connected line segments with N corners (3 < N < 200). The corners or vertices are each distinct and are listed in counter-clockwise order in an array {xi, yi}, i in (1..N).

Every pair of adjacent vertices defines a side of the fence. Thus {xi yi xi+1 yi+1} is a side of the fence for all i in (1..N). For our purposes, N+1 = 1, so that the first and last vertices making the fence closed.

Here is a typical closed fence and a point x,y:

                         * x3,y3
                 x5,y5  / \
    x,y *          *   /   \
                  / \ /     \
                 /   *       \
           x6,y6*   x4,y4     \
                |              \
                |               \
           x1,y1*----------------* x2,y2

Write a program which will do the following:

  • Test an ordered list of vertices {xi,yi}, i in (1..N) to see if the array is a valid fence.
  • Find the set of fence sides that a person (with no height) who is standing in the plane at position (x,y) can "see" when looking at the fence. The location x,y may fall anywhere not on the fence.

A fence side can be seen if there exists a ray that connects (x,y) and any point on the side, and the ray does not intersect any other side of the fence. A side that is parallel to the line of sight is not considered visible. In the figure, above the segments x3,y3-x4,y4; x5,y5-x6,y6; and x6-y6-x1,y1 are visible or partially visible from x,y.

PROGRAM NAME: fence4

INPUT FORMAT

Line 1: N, the number of corners in the fence
Line 2: Two space-separated integers, x and y, that are the location of the observer. Both integers will fit into 16 bits.
Line 3-N+2: A pair of space-separated integers denoting the X,Y location of the corner. The pairs are given in counterclockwise order. Both integers are no larger than 1000 in magnitude.
NOTE: I have added anNew test case #12 for this task. Let me know if you think it's wrong. Rob Be sure to include USACO in your mail subject!

SAMPLE INPUT (file fence4.in)

13
5 5
0 0
7 0
5 2
7 5
5 7
3 5
4 9
1 8
2 5
0 9
-2 7
0 3
-3 1 

OUTPUT FORMAT

If the sequence is not a valid fence, the output is a single line containing the word "NOFENCE".

Otherwise, the output is a listing of visible fence segments, one per line, shown as four space-separated integers that represent the two corners. Express the points in the segment by showing first the point that is earlier in the input, then the point that is later. Sort the segments for output by examining the last point and showing first those points that are earlier in the input. Use the same rule on the first of the two points in case of ties.

SAMPLE OUTPUT (file fence4.out)

7
0 0 7 0
5 2 7 5
7 5 5 7
5 7 3 5
-2 7 0 3
0 0 -3 1
0 3 -3 1

思路:直接枚举每条边,判断这条边是否能看见,判断方法是:从人所在的位置e 分别与需要判段的边的两端连线,然后判断这两条线是否与其他的边同时非严格相交(可交与边界点),如果是,则这条边肯定被挡住了,否则在看是否有一条连线与其严格相交,有就将这条边砍成两段,继续判断,只要砍出一段不被挡住,这条边就不算被挡住,如果砍到很短的值还找不到,那就算被挡住了。

吐槽下:这道题卡了整一个多月,当

第3章总结1 USACO 第三章通关总结全面的总结2010ADVENTop2010/2/92USACO 第三章通关总结By ADVENTop三章总体上感觉并不太困难,但是有很 立即下载

相关推荐

地磁场仿真与导航方案设计

地磁场仿真与导航方案设计 地磁场作为地球的固有资源,为航空、航天、航海提供了天然的坐标,可应用于航天器、航空飞行器和舰船等载体的定位、定向及姿态控制。本文依据地磁场的球谐模型,利用Matlab工具,设计了计算任意地点地磁场的程序,对仿真结果与实际数据进行对比分析;并选定一组卫星的数据,结合卫星的运动轨道,描绘90分钟内卫星处地磁总强度/矢量随轨道变化曲线,据此设计一种卫星地磁导航方案。 一、地磁场计算原理 1.1.球谐模型与球谐系数 地磁学的基本问题之一就是用数学表达式将地磁要素的地面分布表示成地理坐标的函

PRQKKK的博客 7422

AD9361 官方例程详解(一)

文章目录前言一、pandas是什么?二、使用步骤总结 前言 一、pandas是什么? 二、使用步骤 总结

weixin_44630490的博客 4万+

Cursor 团队代码规范与开发规则

本文提出了一套 Cursor 项目开发规范,涵盖代码结构、命名、日志、测试等关键环节,旨在提升代码质量和团队协作效率。核心规则包括:文件不超过2000行、函数不超过80行;变量命名禁用无意义单词;日志只记录关键信息;配置项禁止硬编码;依赖和敏感信息统一管理;核心逻辑测试覆盖率≥80%;Git提交遵循Conventional Commits规范。通过一个车辆数据处理函数的改造案例,展示了从"不规范"到"规范"的代码优化过程,体现了拆分函数、常量管理、错误处理等规范的实际

1265

Score Matching(得分匹配)

Score Matching(得分匹配)是一种统计学习方法,用于估计概率密度函数的梯度(即得分函数),而无需知道密度函数的归一化常数。这种方法由Hyvärinen在2005年提出,主要用于无监督学习,特别是在密度估计和生成模型中。

weixin_39699362的博客 2174

告别Root!用Python脚本一键解密Android微信EnMicroMsg.db数据库(附完整源码)

本文详细介绍了如何在非Root环境下使用Python脚本一键解密Android微信EnMicroMsg.db数据库。通过ADB调试接口和SQLCipher技术,实现自动化提取和解密微信聊天记录数据库,无需Root权限,适合数据分析师和普通用户安全备份数据。

weixin_29266007的博客 345

25 - GRACE Mascon数据缺失月份数据插值

本篇基于文章的相关内容和文章公开的奇异谱分析(SSA)插值算法程序包,对grace Mascon数据种缺失的月份进行 插值 ,总结了使用程序包的相关过程,可以将该程序应用到其他数据处理插值计算中。

weixin_43339605的博客 1852

YOLO11-Seg优化:卷积变体系列篇 | 动态蛇形卷积(Dynamic Snake Convolution) | ICCV2023

动态蛇形卷积(Dynamic Snake Convolution),增强微小特征提取能力,引入到YOLO11-Seg,与C3k2结合实现二次创新

会AI的学姐 385

yocto系列讲解[技巧篇]72 - BBCLASSEXTEND变量的作用

BBCLASSEXTEND变量的作用

fulinux的博客 3570

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

上一篇: CF-50E-Square Equation Roots(数论)
下一篇: CF-51B - bHTML Tables Analisys(easy+栈)
剑不飞
博客等级 码龄15年 86粉丝 505原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址