题目:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=105&page=show_problem&problem=1246
拓扑排序,直接dfs,具体看刘汝佳的《算法竞赛入门经典》。而且这道题目的题意是一定存在拓扑排序,所以更加简单。
#include<stdio.h> #include<string.h> #define MAXN 100+10 int vis[MAXN],edge[MAXN][MAXN],topo[MAXN],t,n; void dfs(int i) { int j; for(j=1;j<=n;j++) if(edge[i][j]&&!vis[j]) { vis[j]=1; dfs(j); } topo[t--]=i; } int main() { int i,m; for(;;) { scanf("%d%d",&n,&m); if(n==0&&m==0) break; memset(vis,0,sizeof(vis)); memset(edge,0,sizeof(edge)); while(m--) { int a,b; scanf("%d%d",&a,&b); edge[a][b]=1; } t=n; for(i=1;i<=n;i++) if(!vis[i]) { vis[i]=1; dfs(i); } for(i=1;i<=n;i++) { printf("%d",topo[i]); if(i==n) putchar('\n'); else putchar(' '); } } return 0; }
发表评论
-
UVa 10422 Knights in FEN
2012-09-07 08:40 901题目:http://uva.onlinejudge.org/i ... -
UVa 539 The Settlers of Catan
2012-08-31 22:22 28题目:http://uva.onlinejudge.org/i ... -
UVa 301 Transportation
2012-08-31 22:10 34题目:http://uva.onlinejudge.org/i ... -
UVa 639 Don't Get Rooked
2012-08-30 23:01 811题目:http://uva.onlinejudge.org/i ... -
UVa 216 Getting in Line
2012-08-29 20:48 723题目:http://uva.onlinejudge.org/i ... -
UVa 10474 Where is the Marble?
2012-08-28 13:45 851题目:http://uva.onlinejudge.org/i ... -
UVa 592 Island of Logic
2012-08-27 11:05 1639题目:http://uva.onlinejudge ... -
UVa 11205 The broken pedometer
2012-08-25 17:28 1048题目:http://uva.onlinejudge.org/i ... -
UVa 131 The Psychic Poker Player
2012-08-24 22:28 873题目:http://uva.onlinejudge.org/i ... -
UVa 729 The Hamming Distance Problem
2012-08-24 12:18 695题目:http://uva.onlinejudge.org/i ... -
Uva 10098 Generating Fast
2012-08-23 15:28 659题目:http://uva.onlinejudge.org/i ... -
UVa 146 ID Codes
2012-08-20 18:46 763题目:http://uva.onlinejudge.org/i ... -
UVa 10167 Birthday Cake
2012-08-16 20:57 603题目:http://uva.onlinejudge.org/i ... -
UVa 10129 Play on Words
2012-08-15 22:49 1126题目:http://uva.onlinejudge.org/i ... -
UVa 10596 Morning Walk
2012-08-14 22:05 879题目:http://uva.onlinejudge.org/i ... -
Uva 10004 Bicoloring
2012-08-13 23:34 873题目:http://uva.onlinejudge.org/i ... -
Uva 532 Dungeon Master
2012-08-13 23:29 787题目:http://uva.onlinejudge ... -
Uva 439 Knight Moves
2012-08-11 22:24 656题目:http://uva.onlinejudge.org/i ... -
UVa 784 Maze Exploration
2012-08-11 14:09 824题目:http://uva.onlinejudge.org/i ... -
Uva 572 Oil Deposits
2012-08-11 11:43 745题目:http://uva.onlinejudge.org/i ...
相关推荐
Delegated persist ordering 论文的翻译,华中科技大学课程 计算机系统性能与分析课指定翻译论文之一
这有两个文件,分别为inception_v3_weights_tf_dim_ordering_tf_kernels.h5, inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5
deeplabv3_mobilenetv2_tf_dim_ordering_tf_kernels 预训练模型
inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5 可用于keras,tensorflow.keras,特征提取与迁移学习
XZ-Ordering_A_Space-Filling Curve.pdf
online-food-ordering-system-源码.rar
官方h5权重文件,xception_weights_tf_dim_ordering_tf_kernels Linux下是放在“~/.keras/models/”中 windows用户直接将文件放置在:C:\Users\用户名\.keras\models 下即可。官方GitHub下载速度慢,给需要的朋友...
这是我实现的A Learning Based Framework for Depth Ordering的代码, 只包括本文的代码, 还需要做一些配置, 请自行阅读论文和google
resnet50_weights_tf_dim_ordering_tf_kernels.h5 速度快,准确率高,参数不多
inception_v3_weights_tf_dim_ordering_tf_kernels_notop_update Linux下是放在“~/.keras/models/”中 Win下则放在Python的“settings/.keras/models/”中 Windows-weights路径:C:\Users\你的用户名\.keras\models...
resnet50_weights_tf_dim_ordering_tf_kernels_notop Linux下是放在“~/.keras/models/”中 Win下则放在Python的“settings/.keras/models/”中 Windows-weights路径:C:\Users\你的用户名\.keras\models anaconda...
inception-v4_weights_tf_dim_ordering_tf_kernels 2.1版本
resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5 速度快,准确率高,参数不多 50层残差网络模型,权重训练自ImageNet 该模型在Theano和TensorFlow后端均可使用,并接受channels_first和channels_last两种输入...
vgg16_weights_tf_dim_ordering_tf_kernels_notop.rar vgg16 卷积神经网络
resnet50_weights_th_dim_ordering_th_kernels_notop.h5 50层残差网络模型,权重训练自ImageNet 该模型在Theano和TensorFlow后端均可使用,并接受channels_first和channels_last两种输入维度顺序 模型的默认输入尺寸:...
mobilenet_v2_weights_tf_dim_ordering_tf_kernels_1.0_192_no_top.h5,mobilenetv2 tf.keras预训练模型,可用于迁移学习。
TMF622_Product_Ordering_Management_API_REST_Specification_R19.0
vgg19_weights_tf_dim_ordering_tf_kernels_notop.h5 vgg19_weights_th_dim_ordering_tf_kernels_notop.h5