Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⢛⣉⣥⣤⣶⣶⣶⣶⣶⣶⣤⣬⣉⡛⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⣩⣴⣾⣿⣿⣿⣿⣿⣿⡿⠟⠛⠛⠻⢿⣿⣿⣷⣦⣍⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⣡⣾⣿⣿⣿⣿⣿⣿⣿⡿⢃⣴⣾⣿⠋⣁⣀⠙⣿⣿⣿⣿⣷⣌⠹⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⢡⣾⣿⣿⣿⣿⣿⣿⣿⣿⡿⠇⣼⣿⣿⣿⣷⠸⣿⣿⣿⣿⣿⣿⣿⣿⣷⣌⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⣰⣿⣿⣿⣿⣿⣿⣿⡿⡋⢑⣤⣤⡙⢿⣿⡿⠟⣠⣈⠝⠻⣿⣿⣿⣿⣿⣿⣿⣆⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⡟⢰⣿⣿⣿⣿⣿⣿⡿⡃⣠⣾⣿⣿⣿⣷⣶⣶⣶⣾⣿⣿⣷⣄⢈⢿⣿⣿⣿⣿⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⠃⣿⣿⣿⣿⣿⣿⡟⠀⣴⣿⣿⣿⣿⡿⠟⠛⠛⠻⢿⣿⣿⣿⣿⣧⠉⢻⣿⣿⣿⣿⣿⣿⡈⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⡿⢸⣿⣿⣿⣿⣿⣿⢣⢰⣿⣿⣿⣿⠏⣠⣾⣿⣿⣷⣦⠹⣿⣿⣿⣿⡇⡌⣿⣿⣿⣿⣿⣿⡇⢻⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⡇⢸⣿⣿⣿⢿⣿⣿⠸⢸⣿⣿⣿⣿⠀⣿⣿⣿⣿⣿⣿⠄⣿⣿⣿⣿⡇⠀⣿⣿⣿⣿⣿⣿⡇⢸⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⢸⣿⣿⡇⡀⣿⠋⣤⣤⣤⡙⢿⣿⣆⠹⣿⣿⣿⣿⠟⣰⣿⣿⠟⠛⠃⠢⣿⣿⣿⣿⣿⣿⡇⣾⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⡈⣿⣿⡇⢳⣤⣼⣿⣿⣿⣿⢘⣿⣿⣷⣦⣬⣤⣴⣾⣿⡿⢡⣾⣿⣿⣷⡌⢻⣿⣿⣿⣿⢁⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⢧⠸⣿⣿⣄⠻⠿⣿⣿⠿⠋⢼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠸⣿⣿⣿⣿⣿⠘⣿⣿⣿⠏⣼⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠹⣿⣿⣿⣶⣶⣶⣶⣦⣄⡉⣛⠿⠿⠿⠿⠿⠿⠛⠉⣂⣤⣉⡉⢹⠟⣰⣿⣿⠏⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⡘⢿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣭⣥⣤⣤⣴⣶⣿⣿⡿⠋⢀⣡⣴⣿⡿⢋⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣆⡙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣉⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⣋⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣬⣉⡛⠻⠿⠿⠿⠿⠿⠿⠟⢛⣋⣥⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣶⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
- */
- #pragma GCC optimize("Ofast")
- #pragma GCC target("avx2")
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <vector>
- #include <string>
- #include <algorithm>
- #include <cmath>
- #include <stack>
- #include <iomanip>
- #include <fstream>
- #include <string>
- #include <set>
- #include <deque>
- #include <queue>
- #include <map>
- #include <bitset>
- #include <random>
- #include <list>
- #include <unordered_map>
- #include <unordered_set>
- #include <cassert>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- typedef string str;
- //typedef __int128 ultraint;
- #define endl "\n"
- #define sqrt sqrtl
- //#define pow fast_pow
- const ll inf = (ll)1e18 + 7;
- ld eps = 1e-9;
- struct Point {
- ld x, y;
- };
- ld getl(Point a, Point b) {
- return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
- }
- ld getS(Point a, Point b, Point c) {
- ld ab = getl(a, b);
- ld bc = getl(b, c);
- ld ac = getl(a, c);
- ld p = (ab + bc + ac) / 2.0;
- return sqrt(p * (p - ab) * (p - bc) * (p - ac));
- }
- Point base{ inf,inf };
- bool cmp(Point a, Point b) {
- ll ans = (a.x - base.x) * (b.y - base.y) - (b.x - base.x) * (a.y - base.y);
- if (ans == 0) {
- return getl(base, a) < getl(base, b);
- }
- else {
- return ans > 0;
- }
- }
- signed main() {
- #ifdef _DEBUG
- freopen("in.txt", "r", stdin);
- freopen("out.txt", "w", stdout);
- #endif
- freopen("hull.in", "r", stdin);
- freopen("hull.out", "w", stdout);
- ios_base::sync_with_stdio(0);
- cin.tie(NULL);
- cout.tie(NULL);
- ll t = 1;
- //cin >> t;
- while(t--) {
- ll n, i, j, x0, y0, x1, y1;
- ld two = 2.0;
- cin >> n;
- vector <Point> a(n);
- for (i = 0; i < n; i++) {
- cin >> a[i].x >> a[i].y;
- if (a[i].x < base.x) {
- base = a[i];
- }
- else if (a[i].x == base.x && a[i].y < base.y) {
- base = a[i];
- }
- }
- sort(a.begin(), a.end(), cmp);
- vector <Point> path;
- path.push_back(base);
- for (i = 1; i < n; i++) {
- while (!path.empty()) {
- Point u = path.back();
- path.pop_back();
- if (!path.empty()) {
- x0 = a[i].x - u.x;
- y0 = a[i].y - u.y;
- x1 = path.back().x - u.x;
- y1 = path.back().y - u.y;
- ll res = x0 * y1 - x1 * y0;
- if (res > 0) {
- path.push_back(u);
- break;
- }
- }
- else {
- path.push_back(u);
- break;
- }
- }
- path.push_back(a[i]);
- }
- ld ans = 0;
- n = path.size();
- cout << n << endl;
- for (i = 0; i < n; i++) {
- cout << (ll)path[i].x << " " << (ll)path[i].y << endl;
- }
- for (i = 0; i < n; i++) {
- ans += (path[i].x * path[(i + 1) % n].y) - (path[(i + 1) % n].x * path[i].y);
- }
- cout << fixed << setprecision(1)
- << fabs(ans) / two << endl;
- //cout << ans << endl;
- }
- }
- //痛みを受け入れる。 痛みを知っています。 痛みを感じる。 痛みを参照してください。 真の痛みを知らなければ、真の世界を理解することは不可能です。 今、あなたは痛みを知るでしょう。 神の罰!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement