hdu 3342 拓扑模板题
直接上代码吧
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int m,n,map[][],degree[];
int topo()
{
int i,j,k,mark;
for(i=;i<m;i++)
{
mark=;
for(j=;j<m;j++)
{
if(degree[j]==)
{
mark=;
degree[j]=-;
break;
}
}
if(!mark)
return;
for(k=;k<m;k++)
{
if(map[j][k])
degree[k]--;
}
}
return;
}
int main()
{
int a,b,i,j;
while(scanf("%d%d",&m,&n)!=EOF)
{
if(m==&&n==) break;
memset(map,,sizeof(map));
memset(degree,,sizeof(degree));
for(i=;i<n;i++)
{
scanf("%d%d",&a,&b);
if(!map[a][b])
{
map[a][b]=;
degree[b]++;
}
}
int t=topo();
if(t)
printf("YES\n");
else
printf("NO\n");
}
return;
}
hdu 3342 拓扑模板题的更多相关文章
- HDU 2138 Miller-Rabin 模板题
求素数个数. /** @Date : 2017-09-18 23:05:15 * @FileName: HDU 2138 miller-rabin 模板.cpp * @Platform: Window ...
- HDU 3342 拓扑排序模板
Legal or Not Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- hdu 3342 拓扑排序 水
好久没切题 先上水题! 拓扑排序! 代码: #include<iostream> #include<cstdio> #include<cstring> using ...
- HDU 1392 凸包模板题,求凸包周长
1.HDU 1392 Surround the Trees 2.题意:就是求凸包周长 3.总结:第一次做计算几何,没办法,还是看了大牛的博客 #include<iostream> #inc ...
- HDU 2586 (LCA模板题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2586 题目大意:在一个无向树上,求一条链权和. 解题思路: 0 | 1 / \ 2 3 ...
- HDU 2082 母函数模板题
找单词 Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Submit Status De ...
- HDU 2087 kmp模板题
s为主串 t为模板串 求t的nextt 加const #include<stdio.h> #include<string.h> #include<algorithm> ...
- 【网络流#3】hdu 1532 - Dinic模板题
输入为m,n表示m条边,n个结点 记下来m行,每行三个数,x,y,c表示x到y的边流量最大为c 这道题的模板来自于网络 http://blog.csdn.net/sprintfwater/articl ...
- poj 1251 poj 1258 hdu 1863 poj 1287 poj 2421 hdu 1233 最小生成树模板题
poj 1251 && hdu 1301 Sample Input 9 //n 结点数A 2 B 12 I 25B 3 C 10 H 40 I 8C 2 D 18 G 55D 1 E ...
随机推荐
- 服务器(Linux)上运行python总结
跑实验换了几次服务器了,每次遇到相似问题都要重新百度,而且每次百度搜索出的顺序都不一样,又得重新找半天,这次把遇到的问题都总结一下. 1.准备 PuTTY和FileZilla FileZilla使用F ...
- 灵活使用ssh、dsh和pssh高效管理大量计算机
http://os.iyunv.com/art/201012/240113.htm 灵活使用ssh.dsh和pssh高效管理大量计算机 http://os.iyunv.com2010-12-23 09 ...
- linux内核中IS_ALIGNED是如何定义的?
1. 定义如下: (include/linux/kernel.h) #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a ...
- MS-MSMQ:百科
ylbtech-MS-MSMQ:百科 MicroSoft Message Queuing(微软消息队列)是在多个不同的应用之间实现相互通信的一种异步传输模式,相互通信的应用可以分布于同一台机器上,也可 ...
- 03--STL算法(常用算法)
一:常用的查找算法 (一)adjacent_find():邻接查找 在iterator对标识元素范围内,查找一对相邻重复元素,找到则返回指向这对元素的第一个元素的迭代器.否则返回past-the-en ...
- Oracle SQL 脚本跟踪
NC Oracle SQL 脚本跟踪 脚本: select * from v$sqlarea a and a.LAST_ACTIVE_TIME >= to_date( '2013-02-21 1 ...
- SQL Server 2008 R2如何使用正则表达式搜索
正则表达式是简明而灵活的表示法,用于查找和替换各种模式的文本.在 SQL Server Management Studio 的“查找和替换”对话框中的“查找内容”字段中,可以使用一组特定的正则表达式. ...
- Leetcode之148. Sort List Medium
https://leetcode.com/problems/sort-list/ Sort a linked list in O(n log n) time using constant space ...
- C#使用KingAOP实现AOP面向切面编程二
本文继续上篇讲述一下比较复杂点的AOP例子,先新建一个控制台项目,然后同样先在Nuget中搜索安装KingAop到项目中 1.项目结构 2 .定义一个登录实体类User和LoggingAspect切面 ...
- windows服务器入门 php的安装
下载PHP安装包(下载地址: http://windows.php.net/download/ ),本文档以5.3版本为例,选择如下图对应的安装包: 下载完成后进行安装PHP,需要选择Web服务时,选 ...