Pagini recente » Cod sursa (job #1793611) | Cod sursa (job #1385002) | Cod sursa (job #1865526) | Cod sursa (job #2448202) | Cod sursa (job #2883497)
#include <bits/stdc++.h>
using namespace std;
string const& task("infasuratoare");
ifstream fin(task + ".in");
ofstream fout(task + ".out");
using LD = long double;
const int N(12e4 + 5);
struct Point {
LD x, y;
};
Point st[N], v[N];
int n, k;
inline LD Det(Point const& a, Point const& b, Point const& c) {
return ((a.x * b.y + a.y * c.x + b.x * c.y) - (b.y * c.x + a.y * b.x + a.x * c.y));
}
inline bool CmpY(Point const& a, Point const& b) {
return a.y < b.y;
}
inline bool Cmp(Point const& a, Point const& b) {
return (Det(v[1], a, b) > 0.0);
}
inline void Insert(Point const& p) {
while (k > 1 && Det(st[k - 1], st[k], p) <= 0.0)
--k;
st[++k] = p;
}
signed main() {
fin >> n;
for (int i = 1; i <= n; ++i)
fin >> v[i].x >> v[i].y;
sort(v + 1, v + n + 1, CmpY);
sort(v + 2, v + n + 1, Cmp);
st[++k] = v[1];
st[++k] = v[2];
for (int i = 3; i <= n; ++i)
Insert(v[i]);
Insert(v[1]);
fout << --k << '\n';
fout << fixed << setprecision(12);
for (int i = 1; i <= k; ++i)
fout << st[i].x << ' ' << st[i].y << '\n';
return 0;
}