Pagini recente » Cod sursa (job #1611087) | Istoria paginii runda/oni2011 | Cod sursa (job #1699149) | Cod sursa (job #503281) | Cod sursa (job #1290492)
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "infasuratoare";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif // HOME
typedef long long int lld;
typedef pair<int, int> PII;
typedef pair<int, lld> PIL;
typedef pair<lld, int> PLI;
typedef pair<lld, lld> PLL;
typedef pair<double, double> Point;
const int INF = (1LL << 30) - 1;
const lld LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int MOD = (int)(1e9) + 7;
const int NMAX = 500000 + 5;
const int MMAX = 100000 + 5;
const int KMAX = 100000 + 5;
const int PMAX = 100000 + 5;
const int LMAX = 100000 + 5;
const int VMAX = 100000 + 5;
int N, top;
Point P[NMAX];
Point H[NMAX];
double cp(Point A, Point B, Point C) {
return (A.first - C.first) * (B.second - C.second) - (A.second - C.second) * (B.first - C.first);
}
struct cmp {
bool operator()(Point A, Point B) {
return cp(A, B, P[1]) > 0;
}
};
int main() {
int i;
#ifndef ONLINE_JUDGE
freopen(inputFile.c_str(), "r", stdin);
freopen(outputFile.c_str(), "w", stdout);
#endif
scanf("%d", &N);
for(i = 1; i <= N; i++) {
scanf("%lf%lf", &P[i].first, &P[i].second);
if(P[i] < P[1])
swap(P[i], P[1]);
}
sort(P + 2, P + N + 1, cmp());
for(i = 1; i <= N; i++) {
while(top >= 2 && cp(H[top - 1], H[top], P[i]) < 0)
top--;
H[++top] = P[i];
}
printf("%d\n", top);
for(i = 1; i <= top; i++)
printf("%.12f %.12f\n", H[i].first, H[i].second);
return 0;
}