题目大意: 有一棵有根树,根为 1 ,点有点权.现在有 m 次操作,操作有 3 种:1 x y w ,将 x 到 y 的路径上的点点权加上 w (其中 w=±1w=±1 ):2 x y ,询问在 x 到 y 的路径上有多少个点点权 >0 :3 x ,询问在 x 的子树里的点有多少个点点权 >0 . 数据范围:$n,m≤10^5$,点权的绝对值$≤10^9$. 这一题正常的做法并不是特别优秀,我们考虑一些分块做法 考虑求一个连续的区间内有多少个数$>0$,我们显然可以将原序列分成$\sqr
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the labels are 0. We define this kind of operation: given a subtree, negate all its labels. An
A Simple Tree Problem Time Limit: 3000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ID: 368664-bit integer IO format: %lld Java class name: Main Prev Submit Status Statistics Discuss Next Type: None None Graph Theory 2-
I. A Simple Tree Problem Time Limit: 3000ms Memory Limit: 65536KB 64-bit integer IO format: %lld Java class name: Main Given a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the labels are 0. We define this kind of
uoj450 [集训队作业2018]复读机(生成函数,单位根反演) uoj 题解时间 首先直接搞出单个复读机的生成函数 $ \sum\limits_{ i = 0 }^{ k } [ d | i ] \frac{ x^{ i } }{ i! } $ . 容易想到直接上单位根反演: \[\begin{aligned} \sum\limits_{ i = 0 }^{ k } [ d | i ] \frac{ x^{ i } }{ i! } & = \sum\limits_{ i = 0 }^{ k
目录 @description@ @solution@ @accepted code@ @details@ @description@ 有一棵有根树,根为 1,点有点权. 现在有 m 次操作,操作有 3 种: 1 x y w,将 x 到 y 的路径上的点点权加上 w (其中 w=±1): 2 x y,询问在 x 到 y 的路径上有多少个点点权 >0: 3 x,询问在 x 的子树里的点有多少个点点权 >0. 输入格式 第一行三个数 n,m,T,表示树的结点个数,操作个数,和是否加密. 接下来 n
Tree 思路: 树形dp 注意0不存在逆元,任何一个数乘以0就变成0了,就没有价值浪,所以要暴力转移 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pi acos(-1.0) #define LL long lon