# include int a[25][1010], vis[25][1010] ;int n, m, INF = 0x0f0f0f0f ;int max(int a, int b){return a>b?a:b;}int dfs(int x, int y){ int i, rtn = -IN...
分类:
其他好文 时间:
2014-08-13 18:14:06
阅读次数:
219
N皇后问题
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 8525 Accepted Submission(s): 3802
Problem Description
在N*N的方格棋盘放置了N个皇后,使得它...
分类:
其他好文 时间:
2014-08-13 13:06:06
阅读次数:
210
POJ 1856 Sea Battle(dfs)...
分类:
其他好文 时间:
2014-08-13 10:35:05
阅读次数:
259
来源: http://poj.org/problem?id=1270
Following Orders
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 3812
Accepted: 1512
Description
Order is an...
题意 图中每个矩形'#'连通块代表一艘船 若一艘船与另一艘有边相邻或有角相邻 那么认为这两艘船相撞 若图中有船相撞 输出bad 否则输出图中有多少艘船
可以把图的周围全包上一圈'.' 遍历图中每个点 可知当图中存在一下四种结构中的一个时 必有船相撞 输出并退出循环 否则则dfs这个点 若图中不存在这些结构 就可以输出连通块数量即轮船数了...
分类:
其他好文 时间:
2014-08-13 01:17:55
阅读次数:
289
Description
Karel is a robot who lives in a rectangular coordinate system where each place is designated by a set of integer coordinates (x and y). Your job is to design a program that will help ...
分类:
其他好文 时间:
2014-08-13 01:17:24
阅读次数:
312
题目:Walking on a Grid
题目大意:给出N * N的矩阵,每个格子里都有一个值,现在要求从(1,1)走到(n, n),只能往下,左,右这三个方向走,并且要求最多只能取k个负数,求这样的要求下能得到的走过格子的值之和最大。
解题思路:记忆化搜索,但是这里要四维的,因为要记录方向,为了防止走回头的路,并且取了几个负数也要记录。然后就是dfs了。状态转移方程:dp【x...
分类:
其他好文 时间:
2014-08-13 01:16:55
阅读次数:
222
[1] POJ-1273题目:http://poj.org/problem?id=1273最直接的最大流问题,用了Ford-Fulkerson方法,DFS随机搜索增广路.算法原理参考:http://blog.csdn.net/smartxxyx/article/details/9293665/***...
分类:
其他好文 时间:
2014-08-13 01:05:04
阅读次数:
181
#include
#include
#include
#include
#include
#include
#include
#include
#define N 110
int a,b,step=0;
int anw=0;
int moun[N][N];
int dp[N][N];
int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
using ...
分类:
其他好文 时间:
2014-08-12 17:21:46
阅读次数:
150