Pagini recente » Cod sursa (job #692786) | Cod sursa (job #1493414) | Cod sursa (job #2137071) | Cod sursa (job #771198) | Cod sursa (job #2575569)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("infasuratoare.in");
ofstream fout ("infasuratoare.out");
void usain_bolt()
{
ios::sync_with_stdio(false);
fin.tie(0);
}
const int N = 120005;
const long double EPS = 1e-12;
struct solve
{
long double x, y;
} a[N];
long double c_p(solve a, solve b, solve c)
{
return (b.y - a.y) * (c.x - a.x) - (c.y - a.y) * (b.x - a.x);
}
bool cmp(solve x, solve y)
{
return c_p(a[1], x, y) > 0;
}
int st[N];
int main()
{
usain_bolt();
int n, chosen = -1, k = 2;
fin >> n;
for(int i = 1; i <= n; ++i) {
fin >> a[i].x >> a[i].y;
if(chosen == -1 || a[i].x < a[chosen].x || (a[i].x == a[chosen].x && a[i].y < a[chosen].y)) chosen = i;
}
swap(a[1], a[chosen]);
sort(a + 2, a + 1 + n, cmp);
st[1] = 1;
st[2] = 2;
for(int i = 3; i <= n; ++i) {
while(k >= 2 && c_p(a[st[k - 1]], a[st[k]], a[i]) < EPS) --k;
st[++k] = i;
}
fout << k << "\n";
for(int i = k; i >= 1; --i) fout << fixed << setprecision(12) << a[st[i]].x << " " << a[st[i]].y << "\n";
return 0;
}