题意:给一段0-8000的线段染色 问最后 颜色x 有几段 题解:标准线段树  但是没有push_up  最后查询是单点按顺序查询每一个点 考虑过使用区间来维护不同的线段有多少种各色的线段  思路是 两个子区间合并:左子区最右边和右子区最左边如果相同,那么就不变,不同就+1  但是不好维护  所以直接单点查还更方便 注意  染色是染区间不是染点 例如   0  3是染  0 1 2 3这4个数中间的空  如果不考虑清楚这一点就会导致 染了  2-3 颜色1  0 2颜色2   3-4颜色3  0…
有一块很长的画布,现在想在这块画布上画一些颜色,不过后面画的颜色会把前面画的颜色覆盖掉,现在想知道画完后这块画布的颜色分布,比如 1号颜色有几块,2号颜色有几块.... *********************************************************************** 分析:基本上跟帖海报是一样的,不过最后要求输出的是这种颜色的画有几块,可以按照贴海报的方式先做出来,然后对每个点进行查询,不晓得复杂度会不会太高.不过还是先试一下吧. 注意:如果出现 …
任意门:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1610 Count the Colors Time Limit: 2 Seconds      Memory Limit: 65536 KB Painting some colored segments on a line, some previously painted segments may be covered by some the subsequent…
链接: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82832#problem/F http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1610 Count the Colors Time Limit: 2 Seconds      Memory Limit: 65536 KB Painting some colored segments on a line, s…
Painting some colored segments on a line, some previously painted segments may be covered by some the subsequent ones. Your task is counting the segments of different colors you can see at last. Input The first line of each data set contains exactly…
#include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> using namespace std; ; struct Node { int l,r; int color; }tr[MAXN*]; int color[MAXN]; int temp; void build(int i,int l,int r) { tr[i].l=l; tr[i].r=r; //-1表…
F - Count the Colors ZOJ - 1610   思路:调了一个小时,但是发现自己线段树木有写错,颜色统计出了错误.但是不明白自己颜色统计为什么错了. 求大佬指点迷津.思路很简单,就是一个裸的线段树.只要推出样例就做出来了. 以下是两种颜色统计: 这是我的错误的: ;i<=;i++){ ]&&vis[i-]!=-) ans[vis[i-]]++; &&vis[i]!=-) ans[vis[i-]]++; } 后来大佬解决了疑惑,改成酱就对了: ;i&…
这个是一个经典线段树染色问题,不过题目给的是左右左右坐标,即[0,3]包含0-1这一段 1-2这一段 2-3这一段,和传统的染色不太一样,不过其实也不用太着急. 我们把左边的坐标+1,即可,那么[0,3]其实变成了[1,3]而线段树是按照点询问的,也就是每个点代表的颜色,我们就有了1,2,3,这个三个,并且避免了线段树编号不能到0的情况,然后代码就十分简单了,无需laze标记,因为每个节点的颜色就可以当成laze标记,然后不断往下pushdown既可以,当时还有一个问题就是线段树访问连续两个节点…
传送门:zoj 3279 Ants Ants Time Limit: 2 Seconds      Memory Limit: 32768 KB echo is a curious and clever girl, and she is addicted to the ants recently. She knows that the ants are divided into many levels depends on ability, also, she finds the number…
AtCoder Regular Contest 069 F Flags 二分,2-sat,线段树优化建图 链接 AtCoder 大意 在数轴上放上n个点,点i可能的位置有\(x_i\)或者\(y_i\) 思路 首先最大值最小,考虑二分答案. 如何check呢. 只有两个坐标,考虑2-sat. 可是边有点多,存不下来,考虑线段树优化建图. 如何建图. 先按照做坐标排序,我们有两个点的范围 [id[x]-mid,id[x]+mid],[id[y]-mid,id[y]+mid]. 这个显然是z选了,区…