careercup4.2
来源:互联网 发布:围棋比赛编排软件 编辑:程序博客网 时间:2024/05/29 15:31
看连通性当然深搜广搜都可以,当然深搜代码更简单。
/*Given a directed graph, design an algorithm to find out whether there is a route be -tween two nodes*/#include <iostream>#include <assert.h>#define N 6using namespace std;bool dfs(int g[][N], int s, int t, int v[]){assert( s < N && s >= 0);assert( t < N && t >= 0);if(g[s][t]) return true;for(int i =0; i<N; i++)if(g[s][i] && !v[i]){v[i] = 1;return dfs(g,i,t,v);}return false;}int main(){int g[N][N]={{0,1,1,0,0,0},{0,0,0,1,0,0},{0,0,0,0,1,1},{0,0,0,0,0,1},{0,0,0,1,0,0},{0,0,0,0,0,0}};int v[N] = {0};cout<<dfs(g,1,5,v)<<endl;cout<<dfs(g,1,4,v)<<endl;}
- careercup4.2
- careercup4
- careercup4.1
- careercup4.3
- careercup4.4
- careercup4.5
- careercup4.6
- careercup4.7
- careercup4.8
- 2
- 2
- 2
- 2
- 2
- 2
- 2
- 2
- 2
- 内部类(一)
- DirectX9 SDK Samples(5) Tutorial 5: Using Texture Maps
- 反射
- 异常:Error: executeQueryForObject returned too many results. 解决方法
- 内部类(二)
- careercup4.2
- 一日一点RakNet(41)--Lobby2Client_360
- 黑客是如何进行IP欺骗的
- CvMat操作
- 异常一(Exception)
- 自己写的一个高精度加法,网上有的都太高深,我本身是新手,写的大概新手比较好懂
- Apache Hadoop 0.23 HDFS Federation介绍
- 异常二(Exception)
- 思科6509-E核心交换机引擎切换测试