- 浏览: 35663 次
文章分类
- 全部博客 (41)
- 卧鸟个去 (2)
- Transform (2)
- Mathmatic (9)
- Plant-Tree (7)
- Data-Struct (12)
- Red-Black-Tree (1)
- Radix-Tree (1)
- Trie (2)
- String (4)
- BST (2)
- Amazing-Union-Find-Set (1)
- HDU (27)
- OJ (32)
- BFS (3)
- Pretty-Suffix-Array (2)
- POJ (6)
- Graceful-Segment-Tree (2)
- Geometry (6)
- Priority-Queue (2)
- Dynamic-Programing (1)
- DP (3)
- LCS (1)
- Convex-Hull (2)
- Triangulation (1)
- DFS (3)
- Combinatorial-Mathematics (2)
- Big-Number (1)
- Statistic (3)
- STL (1)
- Shortest-Path (3)
- ZOJ (1)
- Leftist-Tree (1)
- Prime (1)
- Binary-Index-Tree (1)
- (1)
- Stack (1)
- SPFA (0)
- CRT (1)
逃离迷宫
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3619 Accepted Submission(s): 860
第1行为两个整数m, n (1 ≤ m, n ≤ 100),分别表示迷宫的行数和列数,接下来m行,每行包括n个字符,其中字符'.'表示该位置为空地,字符'*'表示该位置为障碍,输入数据中只有这两种字符,每组测试数据的最后一行为5个整数k, x1, y1, x2, y2 (1 ≤ k ≤ 10, 1 ≤ x1, x2 ≤ n, 1 ≤ y1, y2 ≤ m),其中k表示gloria最多能转的弯数,(x1, y1), (x2, y2)表示两个位置,其中x1,x2对应列,y1, y2对应行。
2 5 5 ...** *.**. ..... ..... *.... 1 1 1 1 3 5 5 ...** *.**. ..... ..... *.... 2 1 1 1 3
no yes
一个杯具。超低B错误!!!!!!!好彩提前出现!!!!!大家一定要记住啊!{=___=}
尼条题,首先就念到就系BFS,标记方向,比较弯数剪枝,考虑卖Start==End,100 100 测试数据都无错。
但系就一直死错!!!!!!!
跟住我就捻系唔系算法错误呢?跟住又捻左一个方法,就系一开始就走同一方向走到底。测试结果全对!!!!!!!!但系又系一直死错!!!!!点解!!!!!天啊~~~!!!!!!!
我蛋裂拉!!!!!!!!!!!
跟住我死命睇………………都系无错………………无错!!!!!!!!!!!
再跟住我绝望………………
我好颓废甘将几个数据合埋几个一起测试(我自己整d测试数据通常系t=1)
第一次:
2
5 5
...**
*.**.
.....
.....
*....
1 1 1 1 3
5 7
..*...*
.*....*
..*...*
..**..*
.......
3 1 1 3 2
答案:
no
yes
无错……………………
第二次:
2
5 7
..*...*
.*....*
..*...*
..**..*
.......
3 1 1 3 2
5 5
...**
*.**.
.....
.....
*....
2 1 1 1 3
答案:
yes
no
!!!!!!!错左!!!!!点解!!!!跟住单独测试:
1
5 5
...**
*.**.
.....
.....
*....
2 1 1 1 3
答案:
yes
!!!!!!!!!!!哦!!!!!!!!我知啦!!!!!!!扑街!!!!!!!!!!
son of the bitch!!!!!!!!!!!!!!!!fuck you ass hole!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!ばがやる!!!!!!
我终于知道我错左咩拉{=______=}凸,其实就系队列ge定义位置问题………………
一开始我系定义全局变量,如果答案系no,第一个样例ge数据会全部出列,但系!!!如果第一个样例系yes!!!就会中途return!!!!队列里面中有剩余ge元素!!!就会影响下一个样例
跟住改左再上交…………………………AC,死……………………扑……………………街
HDU 1728 31ms 364K 1384B C++ 10SGetETernal{(。)(。)}!
#include<queue> #include<iostream> using namespace std; struct node { int x,y,dx,dy; } in,temp; char map[102][102]; int turn[102][102]; int move[4][2]={0,1,1,0,0,-1,-1,0}; int i,j,m,n,k,sx,sy,ex,ey,x,y,T_turn; bool flag; //queue<node>q; //就系呢个杯具WA n次 bool BFS() { queue<node> q; //改左就AC in.x=sx-1; in.y=sy-1; in.dx=-2; in.dy=-2; turn[in.x][in.x]=-1; //因为系一直走到底,所以出列后就一定转弯。 q.push(in); while (!q.empty()) { in=q.front(); q.pop(); T_turn=turn[in.x][in.y]+1; if (turn[in.x][in.y]>k) return 0; for (i=0;i<4;i++) { x=in.x+move[i][0]; y=in.y+move[i][1]; while (x>-1 && y>-1 && x<m && y<n && map[x][y]=='.') { if (turn[x][y]==-1){ //-1姐系未访问过ge点 if (x==ex-1 && y==ey-1 && T_turn<=k) return 1; //呢个都系帮凶。 temp.x=x; temp.y=y; turn[x][y]=T_turn; //改变turn[x][y]值同标记有同样效果,防止同一点多次入列。 q.push(temp); } x+=move[i][0]; y+=move[i][1]; } } } return 0; } int main() { int t; scanf("%d",&t); while (t--) { scanf("%d%d",&m,&n); for (i=0;i<m;i++) scanf("%s",map[i]); for (i=0;i<m;i++) for (j=0;j<n;j++) turn[i][j]=-1; //初始化turn数组-1为未访问 scanf("%d%d%d%d%d",&k,&sy,&sx,&ey,&ex); if (sx==ex && sy==ey) puts("yes"); //考虑起点等于终点 else puts(BFS()?"yes":"no"); } return 0; }
AC之后我就捻我先前果个算法系唔系都系呢个错呢?………………实践中………………
发表评论
-
HDU 1370 Biorhythms
2011-08-03 10:27 1138Biorhythms Time Limit: 2000/10 ... -
HDU 1075 What Are You Talking About
2011-08-04 11:00 825What Are You Talking About Tim ... -
HDU 1058 Humble Numbers
2011-08-02 15:55 1154Humble Numbers Time Limit: 200 ... -
HDU 2095 find your present (2)
2011-08-02 16:13 754find your present (2) Time Lim ... -
HDU 1022 Train Problem I
2011-08-02 21:00 984Train Problem I Time Limit: 20 ... -
2142 HDU box
2011-08-02 21:21 726box Time Limit: 3000/1000 MS ( ... -
HDU 2151 Worm
2011-08-01 20:48 769Worm Time Limit: 1000/1000 MS ... -
HDU 2722 Here We Go(relians) Again
2011-08-02 00:06 957Here We Go(relians) Again Time ... -
HDU 3791 二叉搜索树
2011-08-02 14:26 1152二叉搜索树 Time Limit: 20 ... -
PKU 2352 Stars
2011-07-31 21:47 972Stars Time Limit: 1000MS ... -
PKU 2774 Long Long Message
2011-07-31 21:26 855Long Long Message Time Li ... -
PKU 2777 Count Color
2011-07-31 21:31 761Count Color Time Limit: 1 ... -
HDU 2098 分拆素数和
2011-07-31 21:08 1004分拆素数和 Time Limit: 1000/1000 MS ... -
ZOJ 3512 Financial Fraud .
2011-07-31 20:49 1218Financial Fraud Time Limit: 3 ... -
HDU 1798 Tell me the area .
2011-07-31 20:47 1058Tell me the area Time Limit: 3 ... -
HDU 2962 Trucking .
2011-07-31 20:46 631Trucking Time Limit: 20000/100 ... -
HDU 1596 find the safest road .
2011-07-31 20:45 567find the safest road Time Limi ... -
HDU 2553 N皇后问题 .
2011-07-31 20:20 654N皇后问题 Time Limit: 2000/1000 MS ... -
HDU 1392 Surround the Trees .
2011-07-31 20:19 751Surround the Trees Time Limit: ... -
HDU 1234 开门人和关门人 .
2011-07-31 20:17 632开门人和关门人 Time Limit: 2000/1000 ...
相关推荐
算术(HDU-6715).rar
最短路(HDU-2544).rar
数字图像处理总ppt_hdu_许老师.pdf
算法-数塔(HDU-2084).rar
算法-确定比赛名次(HDU-1285).rar
高级计算机图形学_mm的_重点笔记_hdu_吴xy.pdf
经典算法:(二分匹配,背包专题,筛选法,简单数学题,贪心算法,递推求解,动态规划,并查集,母函数,搜索,组合博弈等入门算法)
HDU的一题........HDU DP动态规
HDU 里面的2000~2099道题目的源码。谢谢支持
杭电 hdu acm 第1084题的解法,ac过了,是一位学长教我的.内有一些中文说明.
杭电的一些acm题目,都是我自己一个一个自己提交的