SGU 124.Broken line
时间限制:0.25s
空间限制:4M
题意:
给出n条线段和一个点,保证所有线段平行X轴或Y,并且闭合成一个多边形。判断这个点的位置是在多边形上,还是多边形内,还是多边形外。
solution:
由于,所有的线段都平行于X轴或Y轴且闭合,那么只要判断在点的正上方有多少条线段即可。
如果是奇数,则在多边形内,偶数在多边形外。特判在多边形上的情况。
参考代码
#include <cstdio>
#include <iostream>
using namespace std;
struct node {
int x1, y1, x2, y2;
} f[11111];
int x, y, n, ans;
int main()
{
scanf ("%d", &n);
for (int i = 1; i <= n; ++i)
{
scanf ("%d %d %d %d", &f[i].x1, &f[i].y1, &f[i].x2, &f[i].y2);
if (f[i].x1 > f[i].x2) swap (f[i].x1, f[i].x2);
if (f[i].y1 > f[i].y2) swap (f[i].y1, f[i].y2);
}
scanf ("%d %d", &x, &y);
int ans = 0;
for (int i = 1; i <= n; ++i)
{
if (f[i].x1 == f[i].x2)
if (x == f[i].x1 && f[i].y1 <= y && y <= f[i].y2)
{ puts ("BORDER"); return 0; }
if (f[i].y1 == f[i].y2)
{
if (y == f[i].y1 && f[i].x1 <= x && x <= f[i].x2)
{ puts ("BORDER"); return 0; }
if (f[i].y1 > y && f[i].x1 < x && x <= f[i].x2) ans++;
}
}
if (ans & 1) puts ("INSIDE");
else puts ("OUTSIDE");
return 0;
}
SGU 124.Broken line的更多相关文章
- SGU 124. Broken line 射线法 eps的精准运用,计算几何 难度:3
124. Broken line time limit per test: 0.25 sec. memory limit per test: 4096 KB There is a closed bro ...
- Broken line - SGU 124(判断点与多边形的关系)
题目大意:RT 分析:构造一条射线,如果穿越偶数条边,那么就在多边形外面,如果穿越奇数条边,那么就在多边形里面. 代码如下: ===================================== ...
- SGU 分类
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...
- 今日SGU 5.9
SGU 297 题意:就是求余数 收获:无 #include<bits/stdc++.h> #define de(x) cout<<#x<<"=" ...
- SGU 128. Snake --- 暴力枚举+并查集+贪心+计算几何
<传送门> 128. Snake time limit per test: 0.25 sec. memory limit per test: 4096 KB There are N poi ...
- all unicode
Unicode Chart Range Decimal Name 0x0000-0x007F 0-127 Basic Latin 0x0080-0x00FF 128-255 Latin-1 Suppl ...
- opencron
opencron 是强大的管理linux crontab任务的系统,基于JAVA开发 http://github.com/wolfboys/opencron 一个功能完善真正通用的linux定时任务调 ...
- JHChart 1.1.0 iOS图表工具库中文ReadMe
JHChart(最新版本1.1.0) 好吧,的确当前的github上已经存有不少的iOS图表工具库,然而,当公司的项目需要图表时,几乎没有哪个第三方能够完全满足我的项目需求.无奈之下,本人不得不花费一 ...
- Transistor 晶体管 场效应 双极型 达林顿 CMOS PMOS BJT FET
Transistor Tutorial Summary Transistor Tutorial Summary Bipolar Junction Transistor Tutorial We can ...
随机推荐
- 深入浅出Node.js (附录A) - 安装Node
A.1 Windows系统下的Node安装 A.2 Mac系统下Node的安装 A.3 Linux系统下Node的安装 A.4 总结 A.5 参考资源
- 谷歌浏览器怎么调试js
首先我们打开开发者工具,你可以直接在页面上点击右键,然后选择审查元素或者在Chrome的工具中找到或者你直接记住这个快捷方式: Ctrl+Shift+I (或者Ctrl+Shift+J直接打开控制台) ...
- bzoj 1188 [HNOI2007]分裂游戏(SG函数,博弈)
1188: [HNOI2007]分裂游戏 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 733 Solved: 451[Submit][Status ...
- Getting Started · Building a RESTful Web Service
Getting Started · Building a RESTful Web Service undefined
- Qt 线程基础(Thread Basics的翻译,线程的五种使用情况)
Qt 线程基础(QThread.QtConcurrent等) 转载自:http://blog.csdn.net/dbzhang800/article/details/6554104 昨晚看Qt的Man ...
- linux操作系统cron详解
Linux操作系统定时任务系统 Cron 入门 cron是一个linux下的定时执行工具,可以在无需人工干预的情况下运行作业.由于Cron 是Linux的内置服务,但它不自动起来,可以用以下的方法启动 ...
- windows 下删除.svn文件
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN] @= ...
- 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(36)-文章发布系统③-kindeditor使用
原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(36)-文章发布系统③-kindeditor使用 我相信目前国内富文本编辑器中KindEditor 属于前 ...
- 基于Visual C++2012拆解世界五百强面试题--题3
请用C语言实现 输入N,打印N*N矩阵 比如 N = 3, 打印: 1 2 3 8 9 4 7 6 5 N = 4, 打印 1 2 3 4 12 13 14 5 11 16 ...
- docker 镜像和容器的批量清理
镜像和容器的清理 删除所有运行中的容器 $ docker kill $(docker ps -q) 删除所有停止的容器 $ docker rm $(docker ps -a -q) 删除所有没有tag ...