直接上代码吧

#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 拓扑模板题的更多相关文章

  1. HDU 2138 Miller-Rabin 模板题

    求素数个数. /** @Date : 2017-09-18 23:05:15 * @FileName: HDU 2138 miller-rabin 模板.cpp * @Platform: Window ...

  2. HDU 3342 拓扑排序模板

    Legal or Not Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...

  3. hdu 3342 拓扑排序 水

    好久没切题  先上水题! 拓扑排序! 代码: #include<iostream> #include<cstdio> #include<cstring> using ...

  4. HDU 1392 凸包模板题,求凸包周长

    1.HDU 1392 Surround the Trees 2.题意:就是求凸包周长 3.总结:第一次做计算几何,没办法,还是看了大牛的博客 #include<iostream> #inc ...

  5. HDU 2586 (LCA模板题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2586 题目大意:在一个无向树上,求一条链权和. 解题思路: 0 | 1 /   \ 2      3 ...

  6. HDU 2082 母函数模板题

    找单词 Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Submit Status De ...

  7. HDU 2087 kmp模板题

    s为主串 t为模板串 求t的nextt 加const #include<stdio.h> #include<string.h> #include<algorithm> ...

  8. 【网络流#3】hdu 1532 - Dinic模板题

    输入为m,n表示m条边,n个结点 记下来m行,每行三个数,x,y,c表示x到y的边流量最大为c 这道题的模板来自于网络 http://blog.csdn.net/sprintfwater/articl ...

  9. 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 ...

随机推荐

  1. CV_Learn

    CV学习进度条记录,也是SRTP的进度记录. 阶段一(2019.4-2019.5): 1.opencv简单操作学习.(实现了一些基础操作,从颜色通道到边缘轮廓,2019.4.22完成) 2.linux ...

  2. window.postMessage 跨窗口,跨iframe javascript 通信

    同源通信 执行它们的页面位于具有相同的协议(http/https),端口(80/443),主机(通常为域名) 时,这两个脚本才能相互通信 大多数情况下,网站就是内部的域名,所以是同源通信,可以相互访问 ...

  3. arcgis python 刷新

    arcpy.RefreshActiveView() 刷新地图和布局窗口 arcpy.RefreshTOC() 刷新内容列表 arcpy.RefreshCatalog(r"F:\tknew10 ...

  4. python wmi远程数据获取

  5. linux 之oracle静默安装

    一.安装前准备工作1.修改主机名#vi /etc/hosts   //并添加内网IP地址对应的hostname,如下127.0.0.1           localhost::1           ...

  6. SpringBoot中的异常处理方式

    SpringBoot中有五种处理异常的方式: 一.自定义错误页面 SpringBoot默认的处理异常机制:SpringBoot默认的已经提供了一套处理异常的机制.一旦程序出现了异常SpringBoot ...

  7. 多网卡下如何配置指定IP走某个路由器(适用于外网不通,但是钉钉服务器通的情况)

    # 多网卡下如何配置指定IP走某个路由器(适用于外网不通,但是钉钉服务器通的情况) ## 如何查看一个进程建立的网络连接,方式一 - 查看进程pid `ps -ef|grep dingtalk`- 查 ...

  8. es6对象复制合并 Object.assign

    对象的复制 var obj= { a: 1 }; var copy = Object.assign({}, obj); console.log(copy); //{ a: 1 } 对象的合并和封装 v ...

  9. 【转载】 第四范式首席科学家杨强:AlphaGo的弱点及迁移学习的应对(附视频)

    原文地址: https://www.jiqizhixin.com/articles/2017-06-02-2 ============================================= ...

  10. pytorch常用损失函数

    损失函数的基本用法: criterion = LossCriterion() #构造函数有自己的参数 loss = criterion(x, y) #调用标准时也有参数 得到的loss结果已经对min ...