摘要:// 题意:输入标准国际象棋棋盘上的两个格子,求马最少需要多少步从起点跳到终点 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];...
阅读全文
摘要:// 题意:给一个图案,其中'.'表示背景,非'.'字符组成的连通块为筛子。每个筛子里又包含两种字符,其中'X'组成的连通块表示筛子上的点 // 统计每个筛子里有多少个“X”连通块 思路:两次dfs //思路:先dfs找包含X和*的区域,再在*的区域中dfs X的个数#include#include#include#include#include#includeusing n...
阅读全文
摘要:技巧:遍历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,...
阅读全文