题意:一棵树上有m个红色结点,树的边有权值.q次查询,每次给出k个点,每次查询有且只有一次机会将n个点中任意一个点染红,令k个点中距离红色祖先距离最大的那个点的距离最小化.q次查询相互独立. 分析:数据量很... 最大值最小化,二分搜答案.将ST表求lca的dfs函数加一点东西,求出每个点到其最近红色祖先的距离.check函数中,枚举到其红色祖先的距离超过下限的点.设非法点数为p,尝试将其距离通过一次染色缩小.具体做法是求出这p个点的lca,这个点就是要染红的点,因为只有修改这个点,才有可能将所…
Long long ago there is a strong tribe living on the earth. They always have wars and eonquer others.One day, there is another tribe become their target. The strong tribe has decide to terminate them!!!There are m villages in the other tribe. Each vil…
Description     A new Semester is coming and students are troubling for selecting courses. Students select their course on the web course system. There are n courses, the ith course is available during the time interval (Ai,Bi). That means, if you wa…
H题意: 给你一个n个节点n-1条无向边构成的树,每一个节点有一个权值wi,你需要把这棵树划分成k个子树,每一个子树的权值是这棵子树上所有节点权值之和. 你要输出这k棵子树的权值中那个最大的.你需要让输出的结果尽可能小 题解: 二分结果,重要的是判断这个二分的值是否满足题目要求 对于划分子树的选择,就选择子树中权值最大且又满足二分的答案的那个子树 代码: #include <bits/stdc++.h> using namespace std; typedef long long ll; co…
Problem Description   Zero and One are good friends who always have fun with each other. This time, they decide to do something on a tree which is a kind of graph that there is only one path from node to node. First, Zero will give One an tree and ev…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4062 题意: 现在在一条 $x$ 轴上玩植物大战僵尸,有 $n$ 个植物,编号为 $1 \sim n$,第 $i$ 个植物的位置在坐标 $i$,成长值为 $a_i$,初始防御值为 $d_i$. 现在有一辆小车从坐标 $0$ 出发,每次浇水操作必须是先走 $1$ 单位长度,然后再进行浇水,植物被浇一次水,防御值 $d_i+=a_i$. 现在知道,小车最多进行 $m…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4067 题意: 给出 $n$ 本书(编号 $1 \sim n$),第 $i$ 本书的价格为 $a_i$ 元.我现在手上有若干元钱,我买书的策略为从 $1 \sim n$ 依次买书,若遇到价格不超过我手上钱数的,我就买下,否则就跳过. 现在已知我买了 $m$ 本书,请求出我手上最多有多少元钱. Sample Input 4 4 2 1 2 4 8 4 0 100 9…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5458 Problem Description Given an undirected connected graph G with n nodes and m edges, with possibly repeated edges and/or loops. The stability of connectedness between node u and node v is defined by…
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=648&page=show_problem&problem=5159 In normal football games, the winner team gets 3 points, loser team gets 0 point, and if there is a drawgame, bot…
Problem Description You are given a tree with N nodes which are numbered by integers 1..N. Each node is associated with an integer as the weight. Your task is to deal with M operations of 4 types: 1.Delete an edge (x, y) from the tree, and then add a…