题意:

找出不能相互访问的点集的集合的元素数量。

思路:

偏序集最长反链裸题。

代码:

#include<iostream>
#include<cstring>
using namespace std; const int maxn=;
int g[maxn][maxn]; int uN,vN;
int linker[maxn];
bool used[maxn];
bool dfs(int u)
{
for(int v = ; v < vN; v++)
if(g[u][v] && !used[v])
{
used[v] = true;
if(linker[v] == - || dfs(linker[v]))
{
linker[v] = u;
return true;
}
}
return false;
}
int hungary()
{
int res = ;
memset(linker,-,sizeof(linker));
for(int u = ; u < uN; u++)
{
memset(used,false,sizeof(used));
if(dfs(u))res++;
}
return res;
} int main()
{
int n,m,t;
cin>>t;
while (t--)
{
cin>>n>>m;
memset(g,,sizeof(g));
for (int i=; i<=m; i++)
{
int u,v;
cin>>u>>v;
g[u-][v-]=;
}
for (int k=; k<n; k++)
for (int i=; i<n; i++)
for (int j=; j<n; j++)
if (g[i][k] && g[k][j]) g[i][j]=;
uN=vN=n;
cout<<n-hungary()<<endl;
}
return ;
}

2017ICPC南宁 M题 The Maximum Unreachable Node Set【二分图】的更多相关文章

  1. The Maximum Unreachable Node Set

    题目描述 In this problem, we would like to talk about unreachable sets of a directed acyclic graph G = ( ...

  2. 2017ICPC南宁M The Maximum Unreachable Node Set (偏序集最长反链)

    题意:给你一张DAG,让你选取最多的点,使得这些点之间互相不可达. 思路:此问题和最小路径可重复点覆盖等价,先在原图上跑一边传递闭包,然后把每个点拆成两个点i, i + n, 原图中的边(a, b)变 ...

  3. The Maximum Unreachable Node Set 【17南宁区域赛】 【二分匹配】

    题目链接 https://nanti.jisuanke.com/t/19979 题意 给出n个点 m 条边 求选出最大的点数使得这个点集之间 任意两点不可达 题目中给的边是有向边 思路 这道题 实际上 ...

  4. ACM-ICPC 2017 南宁赛区现场赛 M. The Maximum Unreachable Node Set(二分图)

    题目链接:https://nanti.jisuanke.com/t/19979 题意:给出一个 n 个点,m 条边的 DAG,选出最大的子集使得其中结点两两不能到达. 题解:参考自:https://b ...

  5. 2017ICPC南宁补题

    https://www.cnblogs.com/2462478392Lee/p/11650548.html https://www.cnblogs.com/2462478392Lee/p/116501 ...

  6. 欧拉工程第67题:Maximum path sum II

    By starting at the top of the triangle below and moving to adjacent numbers on the row below, the ma ...

  7. LeetCode算法题-Third Maximum Number(Java实现-四种解法)

    这是悦乐书的第222次更新,第235篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第89题(顺位题号是414).给定非空的整数数组,返回此数组中的第三个最大数字.如果不存 ...

  8. 【LeetCode每天一题】Remove Nth Node From End of List(移除链表倒数第N个节点)

    Given a linked list, remove the n-th node from the end of list and return its head. Example:        ...

  9. 2017ICPC南宁赛区网络赛 Minimum Distance in a Star Graph (bfs)

    In this problem, we will define a graph called star graph, and the question is to find the minimum d ...

随机推荐

  1. electron入门笔记(三)- 引入bootstrap

    源码:https://github.com/sueRimn/electron-bootstrap 当引入jQuery和bootstrap文件时,会报错,原因是:electron 的 Renderer ...

  2. [FWT] UOJ #310. 【UNR #2】黎明前的巧克力

    [uoj#310][UNR #2]黎明前的巧克力 FWT - GXZlegend - 博客园 f[i][xor],考虑优化暴力,暴力就是FWT xor一个多项式 整体处理 (以下FWT代表第一步) F ...

  3. RabbitMQ入门-发布订阅模式

    兔子的Publish/Subscribe是这样的: 有个生产者P,X代表交换机,交换机绑定队列,消费者从队列中取得消息.每次有消息,先发到交换机中,然后由交换机负责发送到它已知的队列中. 生产者代码: ...

  4. BeautifulSoup获取图片

    参看文档:https://www.cnblogs.com/forever-snow/p/8506746.html

  5. AOP和IOC

    AOP切面编程,作用:事务,日志,统一调用,统一实现,拦截,分发: 切点:告诉编译器切面作用于哪个package中的class IOC:控制反转,相对于new 对象来说的,依赖注入:AuthorWar ...

  6. 点赞功能与redis的相遇

    https://www.jianshu.com/p/2ab76d5bde71 或者 https://kikoroc.com/2016/06/07/dev-like-function-with-redi ...

  7. (二叉树 bfs) leetcode 199. Binary Tree Right Side View

    Given a binary tree, imagine yourself standing on the right side of it, return the values of the nod ...

  8. sys用户的操作

    oracle中查找某个表属于哪个用户? select owner from dba_tables where table_name=upper('t_l_tradelist' )          1 ...

  9. 转:值得收藏!那些鲜为人知的 Mac OS X 技巧

    看到一篇网友整理的比较好的“那些鲜为人知的 Mac OS X 技巧”,转载过来分享给大家!希望能有帮助. 更多专题,可关注小编[磨人的小妖精],查看我的文章,也可上[风云社区 SCOEE],查找和下载 ...

  10. MySQL复制相关参数详解

    MySQL复制相关参数详解 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.复制相关系统变量 1>.server_id 是必须设置在master和每个slave上的唯一标 ...