HDU 1312 题目大意: 一个地图里面有三种元素,分别为"@",".","#",其中@为人的起始位置,"#"可以想象为墙,然后.为可以走的空地,求人可以走的最大点数. 解题思路:从起点开始,起点的四个方向满足条件的点分别入队(放置重复入队,需只要一入队就标记已访问而不是取出时再进行标记),直至队为空. /*HDU 1312 ----- Red and Black 入门搜索 BFS解法*/ #include <cstd…
Pet Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 535 Accepted Submission(s): 258 Problem Description One day, Lin Ji wake up in the morning and found that his pethamster escaped. He searched in…
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 16995 Accepted: 6921 Special Judge Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains…
Nearest number - 2 Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 3943 Accepted: 1210 Description Input is the matrix A of N by N non-negative integers. A distance between two elements Aij and Apq is defined as |i − p| + |j − q|. Your p…
bfs广度优先搜索模板 本人蒟蒻,为响应号召 写下bfs模板一篇 可以适用于求最短步数,等最优解问题.如有不足或者不对的地方请各位大佬及时指出 ^-^ 欢迎来戳 具体实现代码(C++) 各个模块功能和简单明了 #include <iostream> #include <queue> #include <algorithm> #define N 100 using namespace std; int n, m; int map[N][N]; bool vis[N][N]…