随笔分类 -  图遍历

UVA 439 Knight Moves
摘要:// 题意:输入标准国际象棋棋盘上的两个格子,求马最少需要多少步从起点跳到终点 BFS求最短路: bfs并维护距离状态cnt, vis记录是否访问过 #include#include#include#include#include#includeusing namespace std;int r1, c1, r2, c2;const int N=8;int vis[N][N];... 阅读全文

posted @ 2014-04-12 10:26 katago 阅读(739) 评论(0) 推荐(0) 编辑

UVa657 The die is cast
摘要:// 题意:给一个图案,其中'.'表示背景,非'.'字符组成的连通块为筛子。每个筛子里又包含两种字符,其中'X'组成的连通块表示筛子上的点 // 统计每个筛子里有多少个“X”连通块 思路:两次dfs //思路:先dfs找包含X和*的区域,再在*的区域中dfs X的个数#include#include#include#include#include#includeusing n... 阅读全文

posted @ 2014-04-10 14:52 katago 阅读(258) 评论(0) 推荐(0) 编辑

UVa572 Oil Deposits DFS求连通块
摘要:技巧:遍历8个方向 for(int dr = -1; dr #include#include#include#includeusing namespace std;const int N=102;char buf[N][N];int m, n;int cnt;int dr[]={0, 0, 1, 1, 1, -1, -1, -1};int dc[]={1, -1, -1, 0, 1,... 阅读全文

posted @ 2014-04-04 16:57 katago 阅读(309) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示