离散化+BFS HDOJ 4444 Walk】的更多相关文章

题目传送门 /* 题意:问一个点到另一个点的最少转向次数. 坐标离散化+BFS:因为数据很大,先对坐标离散化后,三维(有方向的)BFS 关键理解坐标离散化,BFS部分可参考HDOJ_1728 */ #include <cstdio> #include <algorithm> #include <cstring> #include <queue> #include <vector> #include <map> #include <…
题目传送门 /* 题意:求从(1, 1)走到(n, m)的二进制路径值最小 BFS+贪心:按照标程的作法,首先BFS搜索所有相邻0的位置,直到1出现.接下去从最靠近终点的1开始, 每一次走一步,不走回头路,只往下或往右走.因为满足i = j + (i - j)的坐标(j, i - j)可能不止一个,选择最小的访问 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath…
Coconuts Time Limit: 9000/4500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 524    Accepted Submission(s): 151 Problem Description TanBig, a friend of Mr. Frog, likes eating very much, so he always has dreams abou…
Walk Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1142    Accepted Submission(s): 195 Problem Description Biaoge is planning to walk to amusement park. The city he lives can be abstracted as…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4444 题意:给你一些n个矩形,给你一个起点,一个终点,要你求从起点到终点最少需要转多少个弯 题解:因为矩形数量很少50个,可以离散化成102*102的坐标,但是人可以贴着墙壁走,但不能穿过墙壁 所以每个点要分成9等分.建筑物的边占1/3,但是这样有漏洞. 1.当两个墙壁贴在一起,中间还可以过,所以要填补中间 2.当两个矩形的角重合,中间也可以过,要填补中间,但是只能填补中间一个点,不能填补全部的9个…
Old MacDonald has a farm and a large potato field, (1010 + 1) × (1010 + 1) square meters in size. The field is divided into square garden beds, each bed takes up one square meter. Old McDonald knows that the Colorado potato beetle is about to invade…
题目传送门 /* BFS:三维BFS,加上方向.用dp[x][y][d]记录当前需要的最少转向数 */ #include <cstdio> #include <algorithm> #include <cstring> #include <queue> #include <cmath> using namespace std; ; const int INF = 0x3f3f3f3f; struct P { int x, y, z; }now,…
题目传送门 题意:中文题面 分析:双层BFS,之前写过类似的题.总结坑点: 1.步数小于等于T都是YES 2. 传送门的另一侧还是传送门或者墙都会死 3. 走到传送门也需要一步 #include <bits/stdc++.h> using namespace std; char maze[2][11][11]; int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1}; int n, m, tot; bool vis[2][11][11]; st…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5335 #include<stdio.h> #include<cstring> #include<cmath> #include<algorithm> using namespace std; ; char R[MAXN][MAXN]; bool used[MAXN][MAXN]; ], yy[]; ] = { , , , -}; ] = { , -, , };…
Problem Description Terrorists put some mines in a crowded square recently. The police evacuate all people in time before any mine explodes. Now the police want all the mines be ignited. The police will take many operations to do the job. In each ope…