AtCoder AGC038D Unique Path (图论)】的更多相关文章

题目链接 https://atcoder.jp/contests/agc038/tasks/agc038_d 题解 orz zjr神仙做法 考虑把所有\(C_i=0\)的提示的两点连边,那么连完之后的每个连通块都是一棵树 那么同一连通块内就不能出现\(C_i=1\)的提示,然后不同连通块之间可以任意连边,但是要满足两个连通块之间只能连一条边,还要连通 设有\(c\)个连通块,那么就要在连通块之间连\(m-(n-c)\)条边 如果没有\(C_i=1\)的提示,就只要求\(c-1\le m-(n-c…
题目来源 https://leetcode.com/problems/unique-paths/ A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bott…
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 respectively in the grid. For example, There is one obstacle in the middl…
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in t…
Unique Path AGC 038 D 考虑如果两个点之间只能有一个边它们就把它们缩起来,那么最后缩起来的每一块都只能是一棵树. 如果两个点之间必须不止一个边,并且在一个连通块,显然无解. 首先把所有树给连好,现在的可用的边的数量只有 $ m - n + c $ 了. 然后两个连通块之间如果有超过一条边,连通块内部的点显然不只一条路径了. 其他情况,如果我们给连通块连边的时候每个连通块都只一直用一个点来往外连,就可以保证所有连通块都满足要求. 如果不存在两个点之间不只一个边的情况 那么只要可…
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 respectively in the grid. For example, There is one obstacle in the middl…
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 respectively in the grid. For example, There is one obstacle in the middl…
题目:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' i…
[题目] A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish'…
题目链接 https://atcoder.jp/contests/agc022/tasks/agc022_c 题解 大水题一道 就他给的这个代价,猜都能猜到每个数只能用一次 仔细想想,我们肯定是按顺序从大到小用,一个数用多次肯定没意义,于是证完了 并且所有元素独立 所以我们就是要从大到小贪心判断每个元素是否能不用 比如当前要判断\(x\)是否能不用,那么就判断用当前已经确定要用的集合并上所有小于\(x\)的数能不能达到目的 这个东西建个图判一下连通性就行了 时间复杂度\(O(N^4)\) 代码…