杭电1198--Farm Irrigation(BFS外…
来源:互联网 发布:数据采集卡原理设计 编辑:程序博客网 时间:2024/05/18 14:26
Benny has a map of his farm, which is an array of marks denotingthe distribution of water pipes over the whole farm. For example,if he has a map
ADC
FJK
IHE
then the water pipes are distributed like
Several wellsprings are found in the center of some squares, sowater can flow along the pipes from one square to another. If waterflow crosses one square, the whole farm land in this square isirrigated and will have a good harvest in autumn.
Now Benny wants to know at least how many wellsprings should befound to have the whole farm land irrigated. Can you helphim?
Note: In the above example, at least 3 wellsprings are needed, asthose red points in Figure 2 show.
# include<stdio.h>
# include<string.h>
int mark[55][55],m,n;//mark[][]做标记用
int dir[4][2]={-1,0,1,0,0,-1,0,1};//某点的四个方向(分别为上,下,左,右);
intflag[][4]={{1,0,1,0},{1,0,0,1},{0,1,1,0},{0,1,0,1},{1,1,0,0},{0,0,1,1},{1,0,1,1},{1,1,1,0},{0,1,1,1},{1,1,0,1},{1,1,1,1}};//分别标记A~F田的管道开口情况,有则为1,无则为0;注意每块田的管道标记方向也依次为上,下,左,右,与dir[4][2]的方向保持一致,这是本题的关键之处,对于后面的搜索,可简化很多!!
char map[55][55];
struct node {
};
void bfs(int a,int b)
{
}
int main()
{
}
- 杭电1198--Farm Irrigation(BFS外…
- hdu 1198 Farm Irrigation【BFS】
- 杭电1198 Farm Irrigation(并查集)
- 杭电OJ——1198 Farm Irrigation (搜索)
- HDU 1198 Farm Irrigation (BFS)
- Farm Irrigation(BFS)
- 【HDU 1198】Farm Irrigation(dfs+并查集+bfs)
- 杭电OJ——1198 Farm Irrigation (并查集)
- HDU 1198 Farm Irrigation
- 1198 Farm Irrigation
- hdu 1198 Farm Irrigation
- hdu 1198 Farm Irrigation
- HDU--1198Farm Irrigation
- hdu 1198 Farm Irrigation
- HDU 1198-Farm Irrigation
- HDU 1198 Farm Irrigation
- hdu 1198 Farm Irrigation
- hdu 1198 Farm Irrigation
- poj3984--迷宫问题(输出最短路径BF…
- PHP 字符串
- poj1226--Substrings
- 杭电1753--大明A+B
- poj1181--变形课(BFS)
- 杭电1198--Farm Irrigation(BFS外…
- 杭电1372--Knight Moves(BFS)
- poj1321--棋盘问题(DFS)
- 杭电1242--Rescue(BFS+优先队列)
- 黑马程序员-day05-面向对象(封装 Encapsulation)
- 杭电1159——Common Subsequence
- 杭电1087--Super Jumping! Jumping…
- iOS中Block介绍(一)基础
- 杭电1059--Dividing(多重背包一)