COT - Count on a tree #tree You are given a tree with N nodes.The tree nodes are numbered from 1 to N.Each node has an integer weight. We will ask you to perform the following operation: u v k : ask for the kth minimum weight on the path from node u …
题目描述 ggwdwsbs最近被Zeratul和Kyurem拉入了日本麻将的坑.现在,ggwdwsbs有13张牌,Kyurem又打了一张,加起来有14张牌.ggwdwsbs想拜托你帮他判断一下,这14张牌能否和. 为了方便起见,本题不考虑字牌,即只有万,筒,条三种类型的牌,牌上带有数字1~9,相同的牌最多可能出现四次. 麻将想要和,必须把14张牌凑成指定的类型——七对子(2222222的形式)或四面子一雀头(23333的形式). 其中,七对子是指14张牌恰好是7对相同的牌(每两对牌不得相同),如…
Tree Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others) Total Submission(s): 1643    Accepted Submission(s): 461 Problem Description   Zero and One are good friends who always have fun with each other. This time, t…
Description A rooted tree is a well-known data structure in computer science and engineering. An example is shown below:    In the figure, each node is labeled with an integer from {1, 2,...,16}. Node 8 is the root of the tree. Node x is an ancestor…
传送门 简单树上操作. 先转边权为点权. 显然所有的询问操作对应的路径会有一些交点,那么我们可以直接二分答案,对于所有大于二分值的询问用树上差分维护,最后dfs一遍每个点被覆盖了几次,当前情况合法当且仅当被覆盖次数与大于二分值的询问数相同且点权值可以使跟二分值相比差最大的询问合法. 代码: #include<bits/stdc++.h> #define N 300005 using namespace std; inline int read(){ int ans=0; char ch=get…
P3128 [USACO15DEC]最大流Max Flow 题目描述 Farmer John has installed a new system of  pipes to transport milk between the  stalls in his barn (), conveniently numbered . Each pipe connects a pair of stalls, and all stalls are connected to each-other via path…
LeetCode 第 165 场周赛 5275. 找出井字棋的获胜者 5276. 不浪费原料的汉堡制作方案 5277. 统计全为 1 的正方形子矩阵 5278. 分割回文串 III C 暴力做的,只能说数据不充分 找出井字棋的获胜者4 题目描述 Description A 和 B 在一个 3 x 3 的网格上玩井字棋. 井字棋游戏的规则如下: 玩家轮流将棋子放在空方格 (" ") 上. 第一个玩家 A 总是用 "X" 作为棋子,而第二个玩家 B 总是用 "…
Leetcode第 217 场周赛 比赛链接:点这里 做完前两题我就知道今天的竞赛我已经结束了 这场比赛思维量还是比较大的. 1673. 找出最具竞争力的子序列 题目 给你一个整数数组 nums 和一个正整数 k ,返回长度为 k 且最具 竞争力 的 nums 子序列. 数组的子序列是从数组中删除一些元素(可能不删除元素)得到的序列. 在子序列 a 和子序列 b 第一个不相同的位置上,如果 a 中的数字小于 b 中对应的数字,那么我们称子序列 a 比子序列 b(相同长度下)更具 竞争力 . 例如…
Solution Tarjan 点双缩点, 加上树上差分计算. 注意特判... 我特判挂了好久呜呜呜 Code #include<cstdio> #include<cstring> #include<algorithm> #include<vector> #define rd read() using namespace std; ; ; ; int head[N], tot; ], Tot; int low[N], dfn[N], cnt, col, c[…
[Codeforces 555E]Case of Computer Network(Tarjan求边-双连通分量+树上差分) 题面 给出一个无向图,以及q条有向路径.问是否存在一种给边定向的方案,使得这q条路径都能被满足.(如果有一条边是从a->b),而经过它的路径是从b->a,那么久不满足).只需要判断,不用输出方案. 分析 对于一个有向环,显然它可以允许各个方向的路径通过.所以我们只要把无向图里的边-双联通分量建成环,然后就不用考虑了.影响答案的只有桥. 所以我们求出所有桥,然后缩点,把图…