HDU5709 : Claris Loves Painting】的更多相关文章

对于每个点维护两棵线段树$T1[x],T2[x]$: $T1[x]$维护$x$子树内,深度在$[l,r]$内的点数,同种颜色有多个的话,保留深度最小的那个. $T2[x]$维护$x$子树内每种颜色的最小深度. 从底向上合并线段树,先合并$T1$,然后合并$T2$的时候,发现有重复点,那么在$T1$里删去深度大的那个,查询直接在$T1$里区间求和即可. 时间复杂度$O((n+m)\log n)$. #include<cstdio> const int N=100010,M=10000000; i…
题意:有n(<=1e5)个点的树,每个点都有颜色(颜色可能重复),有m(<=1e5)个询问,每次询问(x,d)问在x的子树中,与x的距离不超过d的节点有多少种不同的颜色.强制要求在线. 分析: Part A:先考虑颜色不重复的 如果我们能把每个节点的子树信息建成以深度作为下标的线段树,那么就能很简单地应付查询了 这个信息也很明显,就是下标表示深度,权值表示该深度的节点有多少种不同颜色(注意我们先考虑颜色没有重复的) 那么我们可以先对每个节点自己建一个权值线段树,把自己对应深度的那个位置放个1,…
先不考虑层数限制 一棵树上每个点有个颜色,问一棵子树的颜色数 感觉简单多了是吧 考虑每个点的贡献:自己到根的路径上的一个包含自己的连续段 观察最顶端的点的父亲: 它满足有了额外的同色孩子(咦) 这一条链上需要+1(@miaom) 如果差分,就是在这个点+1(@miaom),在最近的有同色孩子的父亲-1,求子树和 最近的有同色孩子的父亲? 根据直觉,它一定是dfs序上和这个点相邻的同色点和这个点的lca 没了 再加上层数限制 相当于一定要在一定的深度以内 所以开主席树保持可持久化(怎么不能离线啊,…
https://www.zybuluo.com/ysner/note/1318613 背景 这玩意来源于一种有局限性的算法. 有一种广为人知的,树上离线维护子树信息的做法. (可以参照luogu3605 [USACO17JAN]Promotion Counting晋升者计数) 用树状数组维护贡献,并把询问挂在点上. 先遍历整棵树. 在进入一个点时,在询问中,把以这个点为根的子树以外的贡献减掉,再遍历这棵树. 当一个点的子树遍历完时,再在树状数组中加上当前点的贡献,并在询问中加上当前所有已遍历部分…
C. DZY Loves Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of n units (they…
题目 Source http://codeforces.com/problemset/problem/444/C Description DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of n units (they are numbered from 1 to n from left to right). The color of t…
http://acm.hdu.edu.cn/showproblem.php?pid=5661 Claris and XOR Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 146    Accepted Submission(s): 51 Problem Description Claris loves bitwise operatio…
Claris and XOR Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 744    Accepted Submission(s): 330 Problem Description Claris loves bitwise operations very much, especially XOR, because it has ma…
题目链接: Wall Painting Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2681    Accepted Submission(s): 857 Problem Description Ms.Fang loves painting very much. She paints GFW(Great Funny Wall) ev…
Wall Painting Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1026    Accepted Submission(s): 280 Problem Description Ms.Fang loves painting very much. She paints GFW(Great Funny Wall) every da…
题目链接: http://codeforces.com/problemset/problem/444/C J. DZY Loves Colors time limit per test:2 secondsmemory limit per test:256 megabytes 问题描述 DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of…
Problem Description Claris loves bitwise operations very much, especially XOR, because it has many beautiful features. He gets four positive integers a,b,c,da,b,c,d that satisfies a\leq ba≤b and c\leq dc≤d. He wants to choose two integers x,yx,y that…
DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of n units (they are numbered from 1 to n from left to right). The color of thei-th unit of the ribbon is i at first. It is colorful enough, but w…
Claris and XOR Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 332    Accepted Submission(s): 135 Problem Description Claris loves bitwise operations very much, especially XOR, because it has ma…
我们求二进制是怎么求的呢:先看看二进制的每一位代表多大:.......32 16 8 4 2 1 假如n=10, ..... 32>n ,不要. 16>n,不要. 8<=n,要,然后n=n-8=2. 4>2,不要. 2<=2,要,n=n-2=0: 0>1,不要. 不要是一位是0,要的一位是1,则10(10)=..001010(2),也就是从高位向低位求,能取则取. 题意:现在对对于这个题,求a<=x<=b,c<=y<=d,使x^y最大(不同位数最…
C. DZY Loves Colors 题目连接: http://codeforces.com/contest/444/problem/C Description DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of n units (they are numbered from 1 to n from left to right). T…
DZY Loves Colors Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 445E64-bit integer IO format: %I64d      Java class name: (Any) DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a…
Wall Painting Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4339    Accepted Submission(s): 1460 Problem Description Ms.Fang loves painting very much. She paints GFW(Great Funny Wall) every…
链接: https://vjudge.net/problem/HDU-4810 题意: Ms.Fang loves painting very much. She paints GFW(Great Funny Wall) every day. Every day before painting, she produces a wonderful color of pigments by mixing water and some bags of pigments. On the K-th day…
Time limit : 2sec / Memory limit : 256MB Score : 700 points Problem Statement Squid loves painting vertices in graphs. There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are pain…
Problem Description As a amateur artist, Xenocide loves painting the wall. The wall can be considered as a line consisting of n nodes. Each node has its own color. Xenocide spends all day in front of the wall. Sometimes, he paints some consecutive no…
[SinGuLaRiTy] Copyright (c) SinGuLaRiTy 2017.  All Rights Reserved. [CQBZOJ 2011] 计算系数 题目描述 给定一个多项式(ax + by)^k,请求出多项式展开后x^n y^m项的系数. 输入 共一行,包含 5 个整数,分别为a,b,k,n,m,每两个整数之间用一个空格隔开. 输出 输出共 1 行,包含一个整数,表示所求的系数,这个系数可能很大,输出对10007 取模后的结果. 样例数据 样例输入 样例输出 1 1 3…
F - DZY Loves Colors DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of n units (they are numbered from 1 to n from left to right). The color of the i-th unit of the ribbon is i at first. It is…
E. DZY Loves Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of n units (they…
Palindrome graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1727    Accepted Submission(s): 525 Problem Description In addition fond of programing, Jack also loves painting. He likes to dra…
Paint The Wall Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3427    Accepted Submission(s): 955 Problem Description As a amateur artist, Xenocide loves painting the wall. The wall can be c…
Paint The Wall Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3114    Accepted Submission(s): 846 Problem Description As a amateur artist, Xenocide loves painting the wall. The wall can be co…
DZY Loves Colors Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Appoint description:  System Crawler  (2014-07-07) Description DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorf…
B - Splatter Painting Time limit : 2sec / Memory limit : 256MB Score : 700 points Problem Statement Squid loves painting vertices in graphs. There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all…
ztr loves substring Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description ztr love reserach substring.Today ,he has n string.Now ztr want to konw,can he take out exactly k palindrome from all substrin…