摘要: 题目大意是找到独立的油田个数,所谓独立就是跟它相邻的八个方向上都不能再有别的油田。思路就是每遇到一个'@'都要将它周围的所有'@'都给改成'*',用DFS跟BFS都可以,这里是DFS的代码:AC code:View Code 1 #include <iostream> 2 #define MAX 101 3 using namespace std; 4 int m, n, count; 5 char map[MAX][MAX]; 6 int dir[8][2] = {{0, 1}, {0, -1}, {1, 0},{-1, 0}, { 阅读全文
posted @ 2012-03-21 20:51 背着超人飞 阅读(140) 评论(0) 推荐(0)
摘要: 这一题是又裸又水的一道BFS题,唯一复杂的地方就是扩展到了三维,但是跟二维的区别不大。直接看代码吧:AC code:View Code 1 #include <iostream> 2 #define MAX 50 3 #define SZ 51 4 using namespace std; 5 struct node{ 6 int x, y, z; 7 int step; 8 }que[MAX*MAX*MAX*2]; 9 int a, b, c, t, flag;10 int map[SZ][SZ][SZ];11 int d[][3]={-1,0,0,1,0,0,0,-1,0... 阅读全文
posted @ 2012-03-21 00:34 背着超人飞 阅读(180) 评论(0) 推荐(0)