Pagini recente » Cod sursa (job #1348147) | Cod sursa (job #872867) | Cod sursa (job #2572775) | Cod sursa (job #217426) | Cod sursa (job #1627792)
#include <fstream>
#include <algorithm>
#include<iomanip>
using namespace std;
ifstream f("infasuratoare.in");
ofstream g("infasuratoare.out");
struct punct
{ double x,y;
} v[120005];
int n,poz,st[120005],vf;
double panta(punct a,punct b,punct c)
{ return(c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y);
}
bool compar(punct a,punct b)
{ return panta(v[1],a,b)>0;
}
int main()
{ f>>n;
poz=1;
for(int i=1;i<=n;i++)
{ f>>v[i].x>>v[i].y;
if(v[i].x<v[poz].x||v[i].x==v[poz].x &&v[i].y<v[poz].x)
{ poz=i;
}
}
swap(v[1],v[poz]);
sort(v+2,v+n+1,compar);
st[++vf]=1;
st[++vf]=2;
for(int i=3;i<=n;i++)
{ while(vf>2&&panta(v[st[vf-1]],v[st[vf]],v[i])<0) vf--;
st[++vf]=i;
}
g<<vf<<endl;
for(int i=vf;i>=1;i--)
g<<fixed<<setprecision(6)<<v[st[i]].x<<' '<<v[st[i]].y<<endl;
return 0;
}