Pagini recente » Cod sursa (job #1654855) | Cod sursa (job #2935166) | Cod sursa (job #2913794) | Cod sursa (job #249792) | Cod sursa (job #2435936)
#include <bits/stdc++.h>
#define X first
#define Y second
#define punct pair<double,double>
using namespace std;
ifstream f("infasuratoare.in");
ofstream g("infasuratoare.out");
const int N = 120010;
const double eps = 0.000000001;
double dist(punct A,punct B)
{
return (A.X-B.X)*(A.X-B.X)+(A.Y-B.Y)*(A.Y-B.Y);
}
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 );
}
punct P[N],P0,P1;
double x,y;
int n;
bool crit(punct A,punct B)
{
double aux=Det(P[0],A,B);
if(aux>eps)return true;
if(aux<-eps)return false;
return dist(P[0],A)>dist(P[0],B);
}
vector<punct> sol;
int main()
{
f>>n;
for(int i=0;i<n;i++)
{
f>>x>>y;
P[i]=make_pair(x,y);
if(P[i]<P[0])swap(P[i],P[0]);
}
sort(P+1,P+n,crit);
int top=2;
for(int i=2;i<n;i++)
{
while(top>1&&Det(P[top-2],P[top-1],P[i])<0)
top--;
P[top++]=P[i];
}
g<<top<<'\n';
for(int i=0;i<top;i++)
g<<fixed<<setprecision(12)<<P[i].X<<' '<<P[i].Y<<'\n';
return 0;
}