Pagini recente » Monitorul de evaluare | Borderou de evaluare (job #2993332) | Cod sursa (job #1958190) | Cod sursa (job #3318739) | Cod sursa (job #1958188)
#include <bits/stdc++.h>
using namespace std;
struct dot{
double x;
double y;
}
int n,i,st=0x3f3f3f3f,js=0x3f3f3f3f,poz,last;
dot t[120005],rez[120005];
double f(dot a, dot b, dot c)
{
return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);
}
bool cmp(dot a, dot b)
{
return f(t[1],a,b)<0;
}
int main()
{
ifstream cin("infasuratoare.in");
ofstream cout("infasuratoare.out");
cin>>n;
for (i=1; i<=n; i++)
{
cin>>t[i].x>>t[i].y;
if (t[i].x<st) st=t[i].x,js=t[i].y,poz=i; else if (t[i].x==st) if (t[i].y<js) t[i].y=js,poz=i;
}
swap(t[1],t[poz]);
sort(t+2,t+n+1,cmp);
rez[1]=t[1];
rez[2]=t[2];
last=2;
for (i=3; i<=n; i++)
{
while (last>=2 && f(rez[last-1],rez[last],t[i])>0) last--;
last++;
rez[last]=t[i];
}
cout<<last<<'\n';
for (i=n; i>=1; i--) cout<<setprecision(12)<<fixed<<rez[i].x<<" "<<rez[i].y<<'\n';
}