题意: 找出不能相互访问的点集的集合的元素数量. 思路: 偏序集最长反链裸题. 代码: #include<iostream> #include<cstring> using namespace std; ; int g[maxn][maxn]; int uN,vN; int linker[maxn]; bool used[maxn]; bool dfs(int u) { ; v < vN; v++) if(g[u][v] && !used[v]) { used…
题目描述 In this problem, we would like to talk about unreachable sets of a directed acyclic graph G = (V, E). In mathematics a directed acyclic graph (DAG) is a directed graph with no directed cycles. That is a graph such that there is no way to start a…
题意:给你一张DAG,让你选取最多的点,使得这些点之间互相不可达. 思路:此问题和最小路径可重复点覆盖等价,先在原图上跑一边传递闭包,然后把每个点拆成两个点i, i + n, 原图中的边(a, b)变成(a, b + n),跑一变网络流, 答案就是n - maxflow; 代码: #pragma GCC optimize(3) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma G…
题目链接 https://nanti.jisuanke.com/t/19979 题意 给出n个点 m 条边 求选出最大的点数使得这个点集之间 任意两点不可达 题目中给的边是有向边 思路 这道题 实际上是求 二分图的最大独立集 二分图的最大独立集 = 顶点数 - 二分图最大匹配 相关概念: https://blog.csdn.net/whosemario/article/details/8513836 那操作就是 先Flyod 跑出 可达矩阵 再二分匹配 答案就是 n - res AC代码 #pr…
题目链接:https://nanti.jisuanke.com/t/19979 题意:给出一个 n 个点,m 条边的 DAG,选出最大的子集使得其中结点两两不能到达. 题解:参考自:https://blog.csdn.net/winter2121/article/details/79849472     首先用弗洛伊德跑出一个可达性矩阵,然后从每个点开始 dfs 跑二分图,则最后 dfs 出的路径为若干条链,而对于链显然除了最后一个结点,其他结点都要删除,而其他结点的总数即跑二分图的匹配数,用总…
https://www.cnblogs.com/2462478392Lee/p/11650548.html https://www.cnblogs.com/2462478392Lee/p/11650154.html https://www.cnblogs.com/2462478392Lee/p/11648061.html…
By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 37 42 4 68 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom in triangle.txt (right c…
这是悦乐书的第222次更新,第235篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第89题(顺位题号是414).给定非空的整数数组,返回此数组中的第三个最大数字.如果不存在,则返回最大数量.时间复杂度必须在O(n)中.例如: 输入:[3,2,1] 输出:1 说明:第三个最大值为1. 输入:[1,2] 输出:2 说明:第三个最大值不存在,因此返回最大值2. 输入:[2,2,3,1] 输出:1 说明:请注意,此处的第三个最大值表示第三个最大不同的数字.值为2的两个数字都…
Given a linked list, remove the n-th node from the end of list and return its head. Example:                     Given linked list: 1->2->3->4->5, and n = 2.                     After removing the second node from the end, the linked list beco…
In this problem, we will define a graph called star graph, and the question is to find the minimum distance between two given nodes in the star graph. Given an integer nnn, an n−dimensionaln-dimensionaln−dimensional star graph, also referred to as Sn…