Pagini recente » Cod sursa (job #2753311) | Cod sursa (job #2183061) | Cod sursa (job #2368315) | Cod sursa (job #2647803) | Cod sursa (job #2835588)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("infasuratoare.in");
ofstream fout("infasuratoare.out");
const int dim=200000;
struct pt{
long double x,y;
int ind;
bool operator<(const pt &other) const
{
if(x==other.x){
return y<other.y;
}
return x<other.x;
}
}v[dim];
int ap[dim];
vector<pt>e;
int n,stiva[dim],vf;
void solve(){
vf=0;
for(auto it:e){
long double y=it.y;
int ind=it.ind;
while(vf>=2 && y>=v[stiva[vf]].y && v[stiva[vf]].y<=v[stiva[vf-1]].y){
ap[stiva[vf]]--;
vf--;
}
stiva[++vf]=ind;
ap[ind]++;
}
vf=0;
for(auto it:e){
long double y=it.y;
int ind=it.ind;
while(vf>=2 && y<=v[stiva[vf]].y && v[stiva[vf]].y>=v[stiva[vf-1]].y){
ap[stiva[vf]]--;
vf--;
}
stiva[++vf]=ind;
ap[ind]++;
}
}
signed main(){
fin>>n;
for(int i=1;i<=n;i++){
fin>>v[i].x>>v[i].y;
e.push_back({v[i].x,v[i].y,i});
}
sort(e.begin(),e.end());
solve();
int nr=0;
for(int i=1;i<=n;i++){
if(ap[i]){
nr++;
}
}
fout<<nr<<'\n';
for(int i=1;i<=n;i++){
if(ap[i]){
fout<<fixed<<setprecision(6)<<v[i].x<<' '<<v[i].y<<'\n';
}
}
}