ZOJ Problem Set - 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 ones. Your task is counting the segments of dif…
\[SDOI2017 树点染色\] 题目描述 Bob 有一棵 $ n $ 个点的有根树,其中 $ 1 $ 号点是根节点.Bob 在每个节点上涂了颜色,并且每个点上的颜色不同. 定义一条路径的权值是,这条路径上的点(包括起点和终点)共有多少种不同的颜色. Bob 可能会进行这几种操作: $ 1 x $,把点 $ x $ 到根节点的路径上的所有的点染上一种没有用过的新颜色: $ 2 x y $,求 $ x $ 到 $ y $ 的路径的权值: $ 3 x $,在以 $ x $ 为根的子树中选择…
题目链接: poj 2777 Count Color 题目大意: 给出一块长度为n的板,区间范围[1,n],和m种染料 k次操作,C a b c 把区间[a,b]涂为c色,P a b 查询区间[a,b]有多少种不同颜色 解题思路: 很明显的线段树的区间插入和区间查询,但是如何统计有多少不同的颜色呢? 如果每个结点数组来存储颜色的种类,空间复杂度很高,而且查询很慢 颜色最多只有30种,可以用位运算中的“按位或|” 颜色也用二进制来处理,和存储: 第一种颜色的二进制表示1 第二种颜色…
这个也是一个线段树的模板 #include<iostream> #include<string.h> #include<algorithm> #include<stdio.h> #include<set> using namespace std; ; set<int>s; struct node{ int color; int left; int right; int mid; }a[maxx<<]; void pushd…
Count Color Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 53312 Accepted: 16050 Description Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem.…
题目链接:https://vjudge.net/problem/ZOJ-1610 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 firs…
题目链接:https://vjudge.net/problem/HDU-1698 In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length. Now Pudge wants to do…
题意:给你一棵树,一开始每个点上的颜色互不相同.三种操作:op1:x到根的路径上的点都染上一种新的颜色.op2:设一条路径的权值为val(x,y),求x到y路径的val.op3:询问x的子树中最大的到根路径val.n<=1e5. 标程: #include<bits/stdc++.h> using namespace std; typedef long long ll; ; ; int f[N],prime[N],tot,F[N],ans,p[N],n,m,nxt,u[N],fi[N];…
Mayor's posters Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 59239 Accepted: 17157 Description The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral post…
题目分析: 操作一很明显等价于LCT上的access操作,操作二是常识,操作三转化到dfs序上求最大值也是常识.access的时候顺便在线段树中把对应部分-1,把右子树的子树+1即可. 代码: #include<bits/stdc++.h> using namespace std; ; int num,n,m; vector <int> g[maxn]; int f[maxn],dep[maxn],dfsin[maxn],dfsout[maxn]; class SegmentTre…
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem 10983 18765 Y 1036 [ZJOI2008]树的统计Count 5293 13132 Y 1588 [HNOI2002]营业额统计 5056 13607 1001 [BeiJing2006]狼抓兔子 4526 18386 Y 2002 [Hnoi2010]Bounce 弹飞绵羊 43…
Count Color Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 40510 Accepted: 12215 Description Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem. The…