Pagini recente » Cod sursa (job #1751784) | Cod sursa (job #841745) | Cod sursa (job #2058375) | Cod sursa (job #2085549) | Cod sursa (job #2571745)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("infasuratoare.in");
ofstream fout("infasuratoare.out");
const int Nmax = 120005;
int n, top;
int st[Nmax];
pair <double, double> pct[Nmax];
bitset <Nmax> viz;
inline double side(int a, int b, int c)
{
return pct[c].second * (pct[a].first - pct[b].first) +
pct[c].first * (pct[b].second - pct[a].second) +
pct[a].second * pct[b].first - pct[a].first * pct[b].second;
}
int main()
{
fin >> n;
for(int i = 1; i <= n; i++)
fin >> pct[i].second >> pct[i].first;
sort(pct + 1, pct + n + 1);
st[1] = 1;
st[2] = 2;
top = 2;
viz[2] = 1;
for(int i = 3; i <= n; i++)
{
while(top >= 2 && side(st[top - 1], st[top], i) < 0)
{
viz[st[top]] = 0;
top--;
}
st[++top] = i;
viz[i] = 1;
}
for(int i = n - 1; i >= 1; i--)
if(!viz[i])
{
while(top >= 2 && side(st[top - 1], st[top], i) < 0)
{
viz[st[top]] = 0;
top--;
}
st[++top] = i;
viz[i] = 1;
}
fout << top - 1 << "\n";
fout << fixed << setprecision(12);
for(int i = 1; i < top; i++)
fout << pct[st[i]].second << " " << pct[st[i]].first << "\n";
fin.close();
fout.close();
return 0;
}