时间限制: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的更多相关文章

  1. 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 ...

  2. Broken line - SGU 124(判断点与多边形的关系)

    题目大意:RT 分析:构造一条射线,如果穿越偶数条边,那么就在多边形外面,如果穿越奇数条边,那么就在多边形里面. 代码如下: ===================================== ...

  3. SGU 分类

    http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...

  4. 今日SGU 5.9

    SGU 297 题意:就是求余数 收获:无 #include<bits/stdc++.h> #define de(x) cout<<#x<<"=" ...

  5. SGU 128. Snake --- 暴力枚举+并查集+贪心+计算几何

    <传送门> 128. Snake time limit per test: 0.25 sec. memory limit per test: 4096 KB There are N poi ...

  6. all unicode

    Unicode Chart Range Decimal Name 0x0000-0x007F 0-127 Basic Latin 0x0080-0x00FF 128-255 Latin-1 Suppl ...

  7. opencron

    opencron 是强大的管理linux crontab任务的系统,基于JAVA开发 http://github.com/wolfboys/opencron 一个功能完善真正通用的linux定时任务调 ...

  8. JHChart 1.1.0 iOS图表工具库中文ReadMe

    JHChart(最新版本1.1.0) 好吧,的确当前的github上已经存有不少的iOS图表工具库,然而,当公司的项目需要图表时,几乎没有哪个第三方能够完全满足我的项目需求.无奈之下,本人不得不花费一 ...

  9. Transistor 晶体管 场效应 双极型 达林顿 CMOS PMOS BJT FET

    Transistor Tutorial Summary Transistor Tutorial Summary Bipolar Junction Transistor Tutorial We can ...

随机推荐

  1. Light OJ 1032 - Fast Bit Calculations(数位DP)

    题目大意: 一个数字把他看成二进制数字,数字里又会一些相邻的1,问从0到n至间所有相邻1的总和是多少?   分解成2进制数字,然后数位DP就行了.   ======================== ...

  2. 乐视手机1S正式发售,乐视商城官网抽风遭网友吐槽

    乐视手机1S正式发售,乐视商城官网抽风遭网友吐槽 10月27日,乐视召开的新品发布会上正式推出千元金属新机乐1s,售价1099元.今天11月3日上午10:00,乐1s在乐视商城.京东商城首发开卖,现货 ...

  3. HDOJ 1995 汉诺塔V

    Problem Description 用1,2,-,n表示n个盘子,称为1号盘,2号盘,-.号数大盘子就大.经典的汉诺塔问 题经常作为一个递归的经典例题存在.可能有人并不知道汉诺塔问题的典故.汉诺塔 ...

  4. POJ 1503 Integer Inquiry 简单大数相加

    Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his explo ...

  5. 解压华为P6 UPDATE.APP

    #!/usr/bin/env python # Version: 0.2.201308040830 # Author: linkscue # Function: unpack any hauwei h ...

  6. poj 2752 Seek the Name, Seek the Fame【KMP算法分析记录】【求前后缀相同的子串的长度】

    Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14106   Ac ...

  7. Spring注入-Map

    在spring框架中为Map注入属性 1map映射的对象创建 package com; /** * Map集合在spring中的使用测试 */ public class User { private ...

  8. 使用JavaScript扫描端口

    <html>    <title>端口扫描</title>    <head></head><form><label fo ...

  9. UIView与CALayer的区别,很详细

    研 究Core Animation已经有段时间了,关于Core Animation,网上没什么好的介绍.苹果网站上有篇专门的总结性介绍,但是似乎原理性的东西不多,看得人云山雾罩,感觉,写那篇东西的人, ...

  10. UIButton图文上下对齐

    - (void)centerImageAndTitle:(float)spacing { // get the size of the elements here for readability CG ...