1 /* 2 这道题如果按照度为0的节点来判断的时候,将度为0的节点和其相连的节点(度数并减去1) 3 从图中去掉,如果度为0的节点的个数为0个但是图中的节点没有都去掉的 时候那么说明 4 出现了回路!用这种方法必须将重边去除掉! 5 6 所以推荐用dfs...
分类:
其他好文 时间:
2014-08-14 03:46:37
阅读次数:
202
1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 char map[105][105]; 7 8 int dir[8][2]={0, 1, 1, 0, -1, 0, 0, -1, 1, 1, 1, -1, -.....
分类:
其他好文 时间:
2014-08-14 01:14:27
阅读次数:
266
A Knight's JourneyTime Limit:1000MSMemory Limit:65536KTotal Submissions:30656Accepted:10498DescriptionBackgroundThe knight is getting bored of seeing ...
分类:
其他好文 时间:
2014-08-14 00:58:47
阅读次数:
307
Problem Description
Continuous Same Game is a simple game played on a grid of colored blocks. Groups of two or more connected (orthogonally, not diagonally) blocks that are the same color may be remo...
分类:
其他好文 时间:
2014-08-13 22:29:17
阅读次数:
288
# include int a[25][1010], vis[25][1010] ;int n, m, INF = 0x0f0f0f0f ;int max(int a, int b){return a>b?a:b;}int dfs(int x, int y){ int i, rtn = -IN...
分类:
其他好文 时间:
2014-08-13 18:14:06
阅读次数:
219
N皇后问题
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 8525 Accepted Submission(s): 3802
Problem Description
在N*N的方格棋盘放置了N个皇后,使得它...
分类:
其他好文 时间:
2014-08-13 13:06:06
阅读次数:
210
POJ 1856 Sea Battle(dfs)...
分类:
其他好文 时间:
2014-08-13 10:35:05
阅读次数:
259
来源: http://poj.org/problem?id=1270
Following Orders
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 3812
Accepted: 1512
Description
Order is an...
题意 图中每个矩形'#'连通块代表一艘船 若一艘船与另一艘有边相邻或有角相邻 那么认为这两艘船相撞 若图中有船相撞 输出bad 否则输出图中有多少艘船
可以把图的周围全包上一圈'.' 遍历图中每个点 可知当图中存在一下四种结构中的一个时 必有船相撞 输出并退出循环 否则则dfs这个点 若图中不存在这些结构 就可以输出连通块数量即轮船数了...
分类:
其他好文 时间:
2014-08-13 01:17:55
阅读次数:
289