forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path124.cpp
More file actions
67 lines (61 loc) · 1.23 KB
/
124.cpp
File metadata and controls
67 lines (61 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//ac
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct node {
int s, t, val;
bool operator<(const node p) const {
return val < p.val;
}
};
vector<node> hor, ver;
int n;
int x, y;
bool border() {
for (unsigned int i = 0; i < ver.size(); ++i) if (x == ver[i].val && y >= ver[i].s && y <= ver[i].t)
return true;
for (unsigned int i = 0; i < hor.size(); ++i) if (y == hor[i].val && x >= hor[i].s && x <= hor[i].t)
return true;
return false;
}
bool inside() {
int cnt = 0;
for (unsigned int i = 0; i < ver.size(); ++i) if (x > ver[i].val) {
if (y >= ver[i].s && y < ver[i].t)
cnt++;
else if (y == ver[i].s)
cnt++;
}
return cnt & 1;
}
int main() {
int a, b, c, d;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
node u;
scanf("%d%d%d%d", &a, &b, &c, &d);
if (a == c && b != d) {
if (b > d) swap(b, d);
u.val = a; u.s = b; u.t = d;
ver.push_back(u);
} else if (b == d && a != c) {
if (a > c) swap(a, c);
u.val = b; u.s = a; u.t = c;
hor.push_back(u);
}
}
scanf("%d%d", &x, &y);
if (border())
printf("BORDER\n");
else {
if (inside())
printf("INSIDE\n");
else
printf("OUTSIDE\n");
}
return 0;
}