HDU-1312-Black and Red】的更多相关文章

HDU 1312 题目大意: 一个地图里面有三种元素,分别为"@",".","#",其中@为人的起始位置,"#"可以想象为墙,然后.为可以走的空地,求人可以走的最大点数. 解题思路:从起点开始,起点的四个方向满足条件的点分别入队(放置重复入队,需只要一入队就标记已访问而不是取出时再进行标记),直至队为空. /*HDU 1312 ----- Red and Black 入门搜索 BFS解法*/ #include <cstd…
HDU 1312 题目大意: 一个地图里面有三种元素,分别为"@",".","#",其中@为人的起始位置,"#"可以想象为墙,然后.为可以走的空地,求人可以走的最大点数. 解题思路:从起点开始,从4个方向进行递归遍历(已经访问的点进行标记). /*HDU 1312 ----- Red and Black 入门搜索 */ #include <cstdio> int n, m; //n行m列 int cnt, star…
  HDU 1312:Red and Black Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u   Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. F…
题目代号:HDU 1312 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1312 Red and Black Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 20820    Accepted Submission(s): 12673 Problem Description There i…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1312 Red and Black Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17773    Accepted Submission(s): 10826 Problem Description There is a rectangula…
Red and Black Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 19731    Accepted Submission(s): 11991 Problem Description There is a rectangular room, covered with square tiles. Each tile is col…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1312 Red and Black Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25397    Accepted Submission(s): 15306 Problem Description There is a rectangula…
嗯... 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1312 一道很经典的dfs,设置上下左右四个方向,读入时记下起点,然后跑dfs即可...最后答案加上起点的1,无需回溯!! AC代码: #include<cstdio> #include<iostream> #include<cstring> using namespace std; ][] = {{-, }, {, }, {, -}, {, }}; int n,…
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1312 题目大意:有一间矩形房屋,地上铺了红.黑两种颜色的方形瓷砖.你站在其中一块黑色的瓷砖上,只能向相邻的黑色瓷砖移动,计算你总共能够到达多少块黑色的瓷砖. 要求:输入包含多组数据,每组数据的第一行输入的是两个整数 W 和 H, 分别表示 x 方向与 y 方向上的瓷砖数量,并且 W 和 H 都不超过20.在接下来的 H 行中,每行包含 W 个字符,每个字符表示一块瓷砖的颜色,规则如下: ' . '…
Problem Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can mo…
Red and Black Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8435    Accepted Submission(s): 5248 Problem Description There is a rectangular room, covered with square tiles. Each tile is colore…
Red and Black Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6762 Accepted Submission(s): 4284 Problem Description There is a rectangular room, covered with square tiles. Each tile is colored eit…
Red and Black Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, h…
Problem Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can mo…
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black til…
题目链接 Problem Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he c…
Red and Black Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12935    Accepted Submission(s): 8006 Problem Description There is a rectangular room, covered with square tiles. Each tile is color…
Problem Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can mo…
搜索虐我千万遍@_@-----一道搜索的水题,WA了好多好多次@_@发现是n,m搞反了-_- 题意-- 给出m行 n列的矩形,其中从@出发,不能跳到#,只能跳到'.'问最多能够跳到多少块'.' 直接搜就好,不用剪枝 #include <stdio.h> #include <string.h> int n,m,cnt; char map[1000][1000]; int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}}; void dfs(int x,int…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1312 题目大意:问迷宫中有多少个点被访问. 解题思路: DFS肯定能水过去的.这里就拍了一下BFS. 然后发现自己BFS访问标记有问题,导致某些点被重复访问了. 赶紧改了一下. #include "cstdio" #include "queue" #include "string" #include "cstring" #inc…
Red and Black Tme Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18126    Accepted Submission(s): 11045 Problem Description There is a rectangular room, covered with square tiles. Each tile is color…
Problem Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can mo…
原题链接 题意:“@”为起点,“.”为路,求可以走的格子有多少个(包括起点) 水题 bfs搜一发 思路:只有可以走的节点才能进入队列,所以每次出队列时ans+1就可以了(没有退出条件,所有可进入的节点都要搜索) #include "map" #include "queue" #include "math.h" #include "stdio.h" #include "string.h" #include &…
#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #define max(a, b)(a > b ? a : b) #define N 30 char maps[N][N]; int m, n, ans; ][] = {{, }, {, -}, {, }, {-, }}; void DFS(int x, int y) { int a, b, i; maps[…
I - Red and Black Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1312 Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is stan…
不知道为什么~除了我室友其他的同学都觉得DFS很简单~且比BFS容易得多........我真心不觉得啊T T~我真心觉得BFS比DFS简单得多................= = 为了把DFS完全搞懂,决定做一些DFS的题目....... HDU 2181 哈密顿绕行世界问题 题意: 给出每个城市与之相连的三个城市的编号,求出给定城市环游所有城市,并回到给定城市的所有路线~按字典序输出~ 是一道简单的DFS题目~只要注意输出的第一个和最后一个都是给定城市,以及哈密顿所走城市数即可~ 代码: #…
题目来源  poj 1562 Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous sq…
HDU 1010  (AC) HDU 1015    (AC) HDU 1016     (AC) HDU 1172   (AC) HDU 1312   (AC) POJ 2362  (AC,1011的弱化版,建议先做这题) POJ  1011  (AC,强烈推荐) POJ  3620 HDU 1010代码 /*******************************************************************************/ /* OS : 3.2.0…
hdu 1241 油田  裸DFS 题意:@代表油田 8个方向上还有@就相连 相当于求图中连通子图的个数Sample Input1 1 // n m*3 5*@*@***@***@*@*1 8@@****@*5 5 ****@*@@*@*@**@@@@*@@@**@0 0 Sample Output0122 #include<iostream> #include<cstdio> #include<cstring> #include<string> #incl…
Red and Black Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 13508 Accepted Submission(s): 8375 Problem Description There is a rectangular room, covered with square tiles. Each tile is colored ei…