博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
codevs3044 线段树+扫描线
阅读量:4593 次
发布时间:2019-06-09

本文共 1801 字,大约阅读时间需要 6 分钟。

1 // #pragma comment(linker, "/STACK:1024000000,1024000000")  2 #include 
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 #include
15 // #include
16 using namespace std; 17 #define clc(a,b) memset(a,b,sizeof(a)) 18 #define inf 0x3f3f3f3f 19 #define lson l,mid,rt<<1 20 #define rson mid+1,r,rt<<1|1 21 const int N = 1100; 22 const int MOD = 1e9+7; 23 #define LL long long 24 #define mi() (l+r)>>1 25 double const pi = acos(-1); 26 27 // inline int r() { 28 // int x=0,f=1;char ch=getchar(); 29 // while(ch>'9'||ch<'0') {if(ch=='-') f=-1;ch=getchar();} 30 // while(ch>='0'&&ch<='9') { x=x*10+ch-'0';ch=getchar();}return x*f; 31 // } 32 int n; 33 double hashh[N<<2]; 34 double sum[N<<2]; 35 int color[N<<2]; 36 struct Edge{ 37 double x1,x2,y; 38 int flag; 39 bool operator < (const Edge &a) const{ 40 return y
>1; 49 if(hashh[mid]==x) return mid; 50 else if(hashh[mid]
mid) update(mid+1,r,rt<<1|1,x,y,f); 70 else { 71 update(l,mid,rt<<1,x,mid,f); 72 update(mid+1,r,rt<<1|1,mid+1,y,f); 73 } 74 pushdown(rt,l,r); 75 } 76 int main(){ 77 // int n; 78 while(scanf("%d",&n)){ 79 if(n==0) 80 break; 81 clc(color,0); 82 clc(sum,0); 83 double x1,x2,y1,y2; 84 for(int i=1;i<=n;i++){ 85 scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2); 86 e[i*2-1].x1=e[i*2].x1=x1; 87 e[i*2-1].x2=e[i*2].x2=x2; 88 e[i*2-1].y=y1;e[i*2].y=y2; 89 e[i*2-1].flag=1;e[i*2].flag=-1; 90 hashh[i*2-1]=x1;hashh[i*2]=x2; 91 } 92 sort(e+1,e+1+2*n); 93 sort(hashh+1,hashh+1+2*n); 94 double ans=0; 95 for(int i=1;i<=2*n;i++){ 96 int l=b_s(e[i].x1),r=b_s(e[i].x2)-1; 97 // cout<<"l:"<
<<" "<<"r:"<
<

 

转载于:https://www.cnblogs.com/ITUPC/p/5643275.html

你可能感兴趣的文章
rsync
查看>>
阅读偏底层技术书有感
查看>>
【leetcode】Path Sum
查看>>
URL传递多个参数遇到的bug
查看>>
linux基础-附件1 linux系统启动流程
查看>>
C# 中静态调用C++dll 和C# 中动态调用C++dll
查看>>
linux并发控制之完成量
查看>>
二十、oracle pl/sql基础
查看>>
PHP之旅 php数据类型
查看>>
FPGA中IBERT核的应用(转)
查看>>
堆排序(heapsort)
查看>>
ActiveX控件开发 C#
查看>>
UVa 1149 - Bin Packing
查看>>
C++ Opencv HoughLines()用霍夫变换在二元图像中寻线
查看>>
验证方法学的发展历程及比较
查看>>
[BZOJ1478]Sgu282 Isomorphism
查看>>
UIView 的exclusiveTouch属性
查看>>
遇见未知的自己
查看>>
测试工程师面试
查看>>
读书笔记:JavaScript编程全解
查看>>