HDU 1542:Atlantis(线段树+扫描线+离散化)
发布日期:2021-06-30 16:05:59 浏览次数:2 分类:技术文章

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

线段树+扫描线+离散化模板题目

第一次做这种类型的题目,以前以为比较难,就没敢碰它,现在学起来感觉还挺简单的,对于我来说,这种离散化思想要稍微难理解一点,其他的部分挺简单的
又学到了新东西!!!

参考博客:

详细请看代码:

#include
#include
using namespace std;const int maxn=220;struct Node{ double l,r; double h; int type; Node(double l_=0,double r_=0,double h_=0,int type_=0):l(l_),r(r_),h(h_),type(type_){}}node[maxn];double x[maxn];int tot;double tree[maxn<<2];int cnt[maxn<<2];inline bool cmp(Node a,Node b){ return a.h
>1; if(x[mid]==locate) return mid; if(x[mid]
=r){ cnt[root]+=v; PushUp(root,l,r); return ; } int mid=(l+r)>>1; if(R<=mid) Update(root<<1,l,mid,L,R,v); else if(L>mid) Update(root<<1|1,mid+1,r,L,R,v); else Update(root<<1,l,mid,L,R,v),Update(root<<1|1,mid+1,r,L,R,v); PushUp(root,l,r);}int main(){ int n,m; int C=0; while(scanf("%d",&n)==1&&n){ m=2*n; for(int i=0;i

转载地址:https://kaven.blog.csdn.net/article/details/81198469 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:BZOJ 2565: 最长双回文串(回文树)
下一篇:洛谷 3809 : 后缀排序

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年05月01日 08时49分28秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章