D. Happy Tree Party Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/593/problem/D Description Bogdan has a birthday today and mom gave him a tree consisting of n vertecies. For every edge of the tree i, some number xi was w…
D. Happy Tree Party     Bogdan has a birthday today and mom gave him a tree consisting of n vertecies. For every edge of the tree i, some number xi was written on it. In case you forget, a tree is a connected non-directed graph without cycles. After…
题目链接 题意:就是给你一颗这样的树,用一个$y$来除以两点之间每条边的权值,比如$3->7$,问最后的y的是多少,修改操作是把权值变成更小的. 这个$(y<=10^{18})$除的权值如果是$>=2$,那么最多除60几次就变成0了,问题关键是路径上会有好多1存在,这时候我们可以用并查集把他们并到一块,这样就能跳着查了. 具体查法: 从$u$到$LCA(u,v)$,路径上除一遍. 从$v$到$LCA(u,v)$,路径上除一遍. 修改操作如果变成1,就与前面的点合并. #include &…
C. Propagating tree Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/383/problem/C Description Iahub likes trees very much. Recently he discovered an interesting tree named propagating tree. The tree consists of n nodes numb…
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 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…
简单的树链剖分+线段树 #include<bits\stdc++.h> using namespace std; #define pb push_back #define lson root<<1,l,midd #define rson root<<1|1,midd+1,r ; vector<int>g[M]; ],lazy[M<<],top[M],son[M],fa[M],sz[M],dfn[M],to[M],deep[M],cnt,n; vo…
题意:在一棵N个节点,有边权的树上维护以下操作: 1:单边修改,将第X条边的边权修改成Y 2:区间取反,将点X与Y在树上路径中的所有边边权取反 3:区间询问最大值,询问X到Y树上路径中边权最大值 n<=10000 CAS<=20 思路:做了2天,改出来的一刻全身都萎掉了 边权转点权,点权就是它到父亲的边的边权,加一些反向标记 取反的标记TAG下传时不能直接赋值为-1,而是将原先的标记取反 多组数据时倍增数组,深度也需要清零 树链剖分不能取第一条边,需要+1 ; ..]of record min…
Problem Description For a sequence S1, S2, ... , SN, and a pair of integers (i, j), if 1 <= i <= j <= N and Si < Si+1 < Si+2 < ... < Sj-1 < Sj , then the sequence Si, Si+1, ... , Sj is a CIS(Continuous Increasing Subsequence). The…
http://poj.org/problem?id=3237 题意:树链剖分.操作有三种:改变一条边的边权,将 a 到 b 的每条边的边权都翻转(即 w[i] = -w[i]),询问 a 到 b 的最大边权. 思路:一开始没有用区间更新,每次翻转的时候都更新到叶子节点,居然也能过,后来看别人的发现也是可以区间更新的. 第一种:无区间更新水过 #include <cstdio> #include <algorithm> #include <iostream> #inclu…