Pagini recente » Cod sursa (job #2217648) | Cod sursa (job #932685) | Cod sursa (job #852237) | Cod sursa (job #2654879) | Cod sursa (job #2134355)
#define x first
#define y second
#define ld long double
#define pii pair<long double, long double>
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("infasuratoare.in");
ofstream fout("infasuratoare.out");
const int N_MAX = 120000 + 5;
int n, stsz;
pii pct[N_MAX];
pii st[N_MAX];
ld deter(pii a, pii b, pii c){
return (a.x*b.y + b.x*c.y + a.y*c.x - c.x*b.y - a.x*c.y - b.x*a.y);
}
int main(){
fin >> n;
for(int i = 1; i<=n; ++i)
fin >> pct[i].x >> pct[i].y;
sort(pct + 1, pct + n + 1);
st[1] = pct[1];
stsz = 1;
for(int i = 2; i<=n; ++i){
while(stsz >= 2 and deter(st[stsz-1], st[stsz], pct[i]) > 0)
stsz --;
st[++stsz] = pct[i];
}
for(int i = n-1; i>=1; --i){
while(stsz >= 2 and deter(st[stsz-1], st[stsz], pct[i]) > 0)
stsz --;
st[++stsz] = pct[i];
}
stsz --;
fout << stsz << '\n';
for(int i = stsz; i>=1; --i)
fout << fixed << setprecision(12) << st[i].x << " " << st[i].y << '\n';
return 0;
}
//Andrei Muntean, 2018