Water Tree】的更多相关文章

Water Tree 给出一棵树,有三种操作: 1 x:把以x为子树的节点全部置为1 2 x:把x以及他的所有祖先全部置为0 3 x:询问节点x的值 分析: 昨晚看完题,马上想到直接树链剖分,在记录时间戳时需要记录一下出去时的时间戳,然后就是很裸很裸的树链剖分了. 稳稳的黄名节奏,因为一点私事所以没做导致延迟了 (ps:后来想了一下,不用树链剖分直接dfs序维护也行...) #include <set> #include <map> #include <list> #i…
D. Water Tree Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343/problem/D Description Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either empty or…
原题传送门:CF343D Water Tree 这道题要用树链剖分,我博客里有对树链剖分的详细介绍 这明显是弱智题 树剖套珂朵莉树多简单啊 前置芝士:珂朵莉树 窝博客里对珂朵莉树的介绍 没什么好说的自己看看吧 先树剖一下 第一种操作,把一个点的子树全部变成1 因为做了树剖,所以珂朵莉树区间赋值就可以了 第二种操作就重链往上跳,重链全变成0,珂朵莉树也能完成 第三种操作直接split一下就行 这道题真的很简单,细节看代码(珂朵莉树实际就是一种暴力) 因为数据随机,所以有可能会有点慢 #pragma…
D. Water Tree time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either…
Water Tree http://codeforces.com/problemset/problem/343/D time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Ea…
Water Tree Time Limit: 4000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 343D64-bit integer IO format: %I64d      Java class name: (Any)   Mad scientist Mike has constructed a rooted tree, which consists of n verti…
D. Water Tree   Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either empty or filled with water. The vertices of the tree are numbered from 1 to n with the root at vertex 1. Fo…
Water Tree CodeForces 343D 树链剖分+线段树 题意 给定一棵n个n-1条边的树,起初所有节点权值为0. 然后m个操作, 1 x:把x为根的子树的点的权值修改为1: 2 x:把x结点到根路径上的点修改为0: 3 x:查询结点x的值. 解题思路 这个因为是在树上进行的操作,所以首先需要把树进行一些转化,比如使用dfs序列转变成一维的,这样方便使用线段树或则树状数组来进行操作.但是因为这里的操作2需要把x节点和它的父节点赋值为0,所以需要树链剖分来进行处理. 关于树链剖分的讲…
D. Water Tree time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either…
Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either empty or filled with water. The vertices of the tree are numbered from 1 to n with the root at vertex 1. For each vertex, t…