Pagini recente » Cod sursa (job #1890217) | Cod sursa (job #1866809) | Cod sursa (job #1325713) | Cod sursa (job #1249206) | Cod sursa (job #1852156)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
using namespace std;
const int nmax=120005;
struct punct
{
long double x,y;
}v[nmax],st[nmax];
int i,n,u,j;
long double det(punct A,punct B,punct C)
{
return (A.x*B.y+B.x*C.y+C.x*A.y-A.y*B.x-B.y*C.x-C.y*A.x);
}
bool comp(punct unu,punct doi)
{
return det(v[1],unu,doi)>0;
}
int main()
{
ifstream f("infasuratoare.in");
ofstream g("infasuratoare.out");
f>>n;
for(i=1;i<=n;i++)
{
f>>v[i].x>>v[i].y;
if(v[i].x<v[1].x||(v[i].x==v[1].x&&v[i].y<v[1].y))
swap(v[1],v[i]);
}
sort(v+2,v+n+1,comp);
st[1]=v[1],st[2]=v[2];u=2;
for(i=3;i<=n;i++)
{
while(u>=2&&det(st[u-1],st[u],v[i])<0)
u--;
u++;st[u]=v[i];
}
g<<u<<'\n';
for(i=1;i<=u;i++)
g<<fixed<<setprecision(6)<<st[i].x<<' '<<st[i].y<<'\n';
return 0;
}