-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathG. Geoplano.cpp
105 lines (91 loc) · 2.29 KB
/
G. Geoplano.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.cpp"
#else
#define dbg(...) 42
#endif
#define endl '\n'
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define len(__x) (int)__x.size()
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using vll2d = vector<vll>;
using vi = vector<int>;
using vi2d = vector<vi>;
using pii = pair<int, int>;
using vii = vector<pii>;
using vc = vector<char>;
#define all(a) a.begin(), a.end()
#define pb(___x) push_back(___x)
#define mp(___a, ___b) make_pair(___a, ___b)
#define eb(___x) emplace_back(___x)
int lg2(ll x) {
return __builtin_clzll(1) - __builtin_clzll(x);
}
// vector<string> dir({"LU", "U", "RU", "R", "RD", "D",
// "LD", "L"}); int dx[] = {-1, -1, -1, 0, 1, 1, 1, 0}; int
// dy[] = {-1, 0, 1, 1, 1, 0, -1, -1};
vector<string> dir({"U", "R", "D", "L"});
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
const ll oo = 1e18;
int T(1);
ll cross(ll x1, ll y1, ll x2, ll y2) {
return x1 * y2 - x2 * y1;
}
ll polygonArea(vector<pll>& pts) {
ll ats = 0;
for (int i = 2; i < len(pts); i++)
ats += cross(pts[i].first - pts[0].first,
pts[i].second - pts[0].second,
pts[i - 1].first - pts[0].first,
pts[i - 1].second - pts[0].second);
return abs(ats / 2ll);
}
ll boundary(vector<pll>& pts) {
ll ats = pts.size();
for (int i = 0; i < len(pts); i++) {
ll deltax =
(pts[i].first - pts[(i + 1) % pts.size()].first);
ll deltay =
(pts[i].second - pts[(i + 1) % pts.size()].second);
ats += abs(__gcd(deltax, deltay)) - 1;
}
return ats;
}
ll pickPoints(vector<pll>& pts, bool includeBorder = true) {
ll bounds = boundary(pts);
ll area = polygonArea(pts);
ll inside = area + 1ll - bounds / 2ll;
dbg(bounds);
dbg(inside);
if (includeBorder)
return inside + bounds;
else
return inside;
}
auto solve() {
vector<pll> pts(3);
for (auto& [x, y] : pts) {
cin >> x >> y;
}
ll pickpts = pickPoints(pts, false);
cout << pickpts << endl;
}
int32_t main(void) {
#ifndef LOCAL
fastio;
#endif
// cin >> T;
for (int i = 1; i <= T; i++) {
solve();
}
}
// AC, geometry, pick's theorem