标签:os io line amp ios ef ui algorithm
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL __int64
#define N 210
using namespace std;
struct Line
{
double x,y1,y2;
int f;
}line[N];
struct node
{
int l,r,c;
double ans,lf,rf;
}q[4*N];
double y[N];
bool cmp(Line a, Line b)
{
return a.x < b.x;
}
void build(int l,int r,int rt)
{
q[rt].l=l;
q[rt].r=r;
q[rt].lf=y[l];
q[rt].rf=y[r];
q[rt].ans=0;
q[rt].c=0;
if(l+1==r)
return ;
int m=(l+r)/2;
build(l,m,rt*2);
build(m,r,rt*2+1);
}
int main()
{
int n,K=0,t;
double x1,x2,y1,y2;
while(scanf("%d",&n)!=EOF&&n!=0)
{
K++;
t=1;
while(n--)
{
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
line[t].x=x1;
line[t].y1=y1;
line[t].y2=y2;
line[t].f=1;
y[t]=y1;
t++;
line[t].x=x2;
line[t].y1=y1;
line[t].y2=y2;
line[t].f=-1;
y[t]=y2;
t++;
}
t--;
sort(y+1,y+t+1);
sort(line+1,t+line+1,cmp);
build(1,t,1);
update(1,line[1]);
}
return 0;
}
标签:os io line amp ios ef ui algorithm
原文地址:http://www.cnblogs.com/zhangmingcheng/p/3905702.html