为防止广告,目前nocow只有登录用户能够创建新页面。如要创建页面请先登录/注册(新用户需要等待1个小时才能正常使用该功能)。

Sgu/124

来自NOCOW
< Sgu
跳转到: 导航, 搜索

可以用射线法,但由于线段的特殊性没必要那么麻烦。

#include <stdio.h>
#include <algorithm>
using namespace std;
typedef struct { int x1, y1, x2, y2; } line;
 
line P[10001];
int n;
 
int main()
{
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d %d %d %d", &P[i].x1, &P[i].y1, &P[i].x2, &P[i].y2);
        if (P[i].x1 > P[i].x2) swap(P[i].x1, P[i].x2);
        if (P[i].y1 > P[i].y2) swap(P[i].y1, P[i].y2);
    }
    scanf("%d %d", &P[0].x1, &P[0].y1);
    int cnt = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (P[i].x1 == P[i].x2)
           if (P[0].x1 == P[i].x1 && P[i].y1 <= P[0].y1 && P[0].y1 <= P[i].y2)
              {  printf("BORDER\n"); return 0; }
        if (P[i].y1 == P[i].y2)
        {
           if (P[0].y1 == P[i].y1 && P[i].x1 <= P[0].x1 && P[0].x1 <= P[i].x2)
              {  printf("BORDER\n"); return 0; }
           if (P[i].y1 > P[0].y1 && P[i].x1 < P[0].x1 && P[0].x1 <= P[i].x2) cnt++;
        }
    }
    if (cnt & 1) printf("INSIDE\n"); else printf("OUTSIDE\n");
    return 0;
}
// From FingerSed
个人工具