POJ 1130
大概题意:给出一副图,求从起点到终点 (0->ET) 必须经过的一点。
我的思路:首先DFS求出经过每点的次数,必过的一点的次数一定最高,但是就这样吗?有可能有多个必过的点,所以还要找出离ET最近的点,这里就利用BFS逐层搜索的性质求每点到ET的距离。
#include
#include
#include
#include
#include
...
分类:
其他好文 时间:
2014-08-15 10:43:08
阅读次数:
207
题意:。。。
策略:深搜.
仔细分析我们发现,我们只需要对列进行标记,对于行我们考虑放棋子还是不放就行了。
代码:
#include
#include
char s[10][10];
int n, m;
int vis[10];
int ans;
void dfs(int cur, int step)
{
if(step == m){
ans ++;
return;
}
if...
分类:
其他好文 时间:
2014-08-15 09:30:27
阅读次数:
153
Tempter of the Bone
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 70895 Accepted Submission(s): 19535
Problem Description
The ...
分类:
其他好文 时间:
2014-08-15 00:08:56
阅读次数:
323
解题报告
题目传送门
题意:
求最大的男女匹配数目。
思路:
简单的最大匹配。
#include
#include
#include
using namespace std;
int k,n,m,mmap[1100][1100],vis[550],pre[550];
int dfs(int x)
{
for(int i=1;i<=n;i++){
if(!v...
分类:
其他好文 时间:
2014-08-15 00:07:56
阅读次数:
262
题意:从2出发,要到达3, 0可以通过,碰到1要停止,并且1处要变成0, 并且从起点开始沿着一个方向要一直前进,直至碰到1(或者3)处才能停止,(就是反射来反射去知道反射经过3).如果反射10次还不能到达3,就输出-1.
策略:深搜。
易错点,方向不容易掌握,并且,出题人把n, m顺序反了。
代码:
#include
#include
int map[25][25];
int ans, n...
分类:
其他好文 时间:
2014-08-14 23:55:36
阅读次数:
236
走迷宫
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
一个由n * m 个格子组成的迷宫,起点是(1, 1), 终点是(n, m),每次可以向上下左右四个方向任意走一步,并且有些格子是不能走动,求从起点到终点经过每个格子至多一次的走法数。
输入
第一行一个整数T 表示有T 组测试数据...
分类:
其他好文 时间:
2014-08-14 20:41:50
阅读次数:
232
砍树思路:可以将题目意图转化为:给定一棵树,求其中最接近总权值一半的子树。DFS求每个节点的所有子节点的权值和,遍历每个节点,最接近总权值一半的即为答案。复杂度O(N)。石子游戏:思路:一个Nim博弈问题,寻找一个局面的平衡状态,由于是多堆石子,参看Nim博弈的相关理论。
分类:
其他好文 时间:
2014-08-14 16:39:08
阅读次数:
206
Tempter of the Bone
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
The doggie found a bone in an ancient maze, which fascinated him a lot. However,...
分类:
其他好文 时间:
2014-08-14 14:07:08
阅读次数:
168
dfs:根据行或者列开始,假设根据行,从第1行开始,从第一行的每一列对应的元素开始dfs,直到第n行,输出结果 1 /************************************************************************* 2 > File Name: N-...
分类:
其他好文 时间:
2014-08-14 13:38:48
阅读次数:
211
DescriptionBackgroundOur knight lives on a chessboard that has a smaller area than a regular 8 * 8 board,but it is still rectangular.Can you help this...
分类:
其他好文 时间:
2014-08-14 03:46:57
阅读次数:
305