Description Translated by @Nishikino_Maki from Luogu 行吧是我翻的 Mad scientist Mike has constructed a rooted tree, which consists of n n vertices. Each vertex is a reservoir which can be either empty or filled with water. The vertices of the tree are numb…
题目描述 首先村落里的一共有n座房屋,并形成一个树状结构.然后救济粮分m次发放,每次选择两个房屋(x,y),然后对于x到y的路径上(含x和y)每座房子里发放一袋z类型的救济粮. 然后深绘里想知道,当所有的救济粮发放完毕后,每座房子里存放的最多的是哪种救济粮. 说明 对于20%的数据,1 <= n, m <= 100 对于50%的数据,1 <= n, m <= 2000 对于100%的数据,1 <= n, m <= 100000, 1 <= a, b, x, y &…
Description 给出一个长度为n的序列a和一个整数p 有m组询问,每组询问给出一个区间\([l,r]\) 你需要给出下面这个过程的结果 ans = 0 for i from l to r { ans = ans + a[i] if ans > p then ans = ans - p; } return ans \(n\leq 10^6\) \(m<=2\times10^5\) \(p\leq10^9\) \(-10^9\leq a_i\leq10^9\) Solution 显然一个区…