上一页 1 ··· 7 8 9 10 11
摘要: 原题链接:http://poj.org/problem?id=2251 在三维空间内做BFS。View Code #include <stdio.h>#include <string.h>#include <queue>using namespace std;int L, R, C, ans, sx, sy, sz, ex, ey, ez;char maze[101][101][101];bool vis[101][101][101];int dr[6][3] = {{0, 0, 1}, {0, 0, -1}, {1, 0, 0}, {-1, 0, 0}, 阅读全文
posted @ 2012-09-03 15:34 芒果布丁 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://poj.org/problem?id=1088 动态规划,记忆化搜索。View Code #include <cstdio>#include <cstring>#define MAXN 105#define max(x,y) x > y ? x : yint a[MAXN][MAXN], dp[MAXN][MAXN];int dr[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}};int R, C;int DP(int r, int c){ if(dp[r][c] != -1) { return dp[. 阅读全文
posted @ 2012-09-03 14:45 芒果布丁 阅读(139) 评论(0) 推荐(0) 编辑
摘要: POJ1258 Prim算法。View Code #include <cstdio>#include <cstring>#define MAXN 110int d[MAXN][MAXN];int edge[MAXN]; bool visit[MAXN];int n;int Prim(){ int i, j, k, mst = 0; memset(visit, false, sizeof(visit)); memset(edge, 0x3f, sizeof(edge)); edge[0] = 0; for(i = 0; i < n; i ++) { ... 阅读全文
posted @ 2012-09-02 13:33 芒果布丁 阅读(243) 评论(0) 推荐(0) 编辑
摘要: HDOJ 4334 Trouble If we have two sorted lists of integers A and B, we can easily find in linear time by keeping two pointers if there are a in A and b in B such that a+b=c (c is given). Now, for this problem, we create a sorted list of all sums for S[0] and S[1] (call it M[0]), and a sorted list o.. 阅读全文
posted @ 2012-08-30 11:54 芒果布丁 阅读(219) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11