hdu1026
摘要://BFS+优先队列(打印路径)#include<cstdio>#include<cstdlib>#include<cstring>#include<queue>using namespace std;const int ROW = 101;const int COL = 101;const int DIRS = 4;struct priNode { int x, y, time; friend bool operator < (priNode a, priNode b) { return a.time > b.time; }};st
阅读全文
posted @
2013-04-09 21:37
Try86
阅读(919)
推荐(0)
hdu1242
摘要://bfs+优先队列#include<cstdio>#include<cstring>#include<queue>using namespace std;const int ROW = 201;const int COL = 201;const int DIRS = 4;char map[ROW][COL];int dir[DIRS][2] = {-1,0,0,1,1,0,0,-1};struct priNode { int x, y, time; friend bool operator < (priNode a, priNode b) { ret
阅读全文
posted @
2013-04-09 21:36
Try86
阅读(453)
推荐(0)
RQNOJ 195校园迷宫(简单BFS)
摘要:1 /* 2 * 简单BFS 3 */ 4 5 #include <cstdio> 6 #include <cstring> 7 #include <iostream> 8 9 using namespace std;10 11 const int N = 2005;12 13 int map[N][N];14 bool vis[N][N];15 struct node {16 int x;17 int y;18 int c;19 }Q[N*N], s, e;20 int front, rear;21 int dir[4][2] = {{0, 1}, {..
阅读全文
posted @
2012-05-14 12:40
Try86
阅读(330)
推荐(0)
RQNOJ 153数的计算(简单dfs)
摘要:#include <cstdio>#include <iostream>using namespace std;int ans;void dfs(int n) { for (int i=1; i<=n/2; ++i) { ++ans; dfs(i); }}int main() { int n; while (scanf("%d", &n) != EOF) { ans = 1; dfs(n); printf ("%d\n", ans); } return 0;}
阅读全文
posted @
2012-05-13 13:54
Try86
阅读(161)
推荐(0)
RQNOJ 34紧急救援(简单BFS)
摘要:#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int N = 1005;char map[N][N], vis[N][N];struct node { int x; int y; int c;}Q[N*N], s, e;int front, rear;int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};int BFS(int n) { node first, next; front = rear
阅读全文
posted @
2012-05-13 13:33
Try86
阅读(168)
推荐(0)