Pagini recente » Cod sursa (job #1336219) | Cod sursa (job #728084) | Cod sursa (job #1479170) | Cod sursa (job #539928) | Cod sursa (job #2854595)
#include <fstream>
#include <deque>
#include <vector>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#define MOD 104659
using namespace std ;
ifstream cin ("infasuratoare.in") ;
ofstream cout ("infasuratoare.out") ;
struct pct
{
double x, y ;
};
pct v[120009], aux ;
int n ;
int det(pct a, pct b, pct c)
{
return (b.x - a.x)*(c.y - a.y) - (b.y - a.y)*(c.x - a.x) ;
}
bool ord(pct a, pct b)
{
if(det(aux, a, b) > 0)return 1 ;
return 0 ;
}
int main()
{
cin >> n ;
for(int f = 1 ; f <= n ; f ++)
cin >> v[f].x >> v[f].y ;
/// inf convexa incepea din stanga jos
int mn = 1 ;
for(int f = 2 ; f <= n ; f ++)
if(v[f].y < v[mn].y)mn = f ;
swap(v[mn], v[1]) ;
aux = v[1] ;
/// sortam vectorul in functie de determinanti
sort(v + 2, v + n + 1, ord) ;
int t = 3 ;
for(int f = 3 ; f <= n ; f ++)
{
while(t >= 3 && det(v[t - 2], v[t - 1], v[f]) < 0)
t -- ;
v[t ++] = v[f] ;
}
cout << t - 1 << endl ;
for(int f = t - 1 ; f ; f --)
cout << fixed << setprecision(6) << v[f].x << " " << v[f].y << '\n' ;
return 0 ;
}
/*
17
12.000000 1.000000
3.000000 -6.000000
6.000000 7.000000
-8.000000 12.000000
-12.000000 -11.000000
-6.000000 -3.000000
3.000000 10.000000
-10.000000 0.000000
7.000000 -13.000000
-14.000000 -6.000000
-12.000000 -7.000000
12.000000 -1.000000
-3.000000 -9.000000
11.000000 7.000000
1.000000 10.000000
6.000000 -5.000000
3.000000 11.000000
*/