题意:从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
1 /* 2 这道题如果按照度为0的节点来判断的时候,将度为0的节点和其相连的节点(度数并减去1) 3 从图中去掉,如果度为0的节点的个数为0个但是图中的节点没有都去掉的 时候那么说明 4 出现了回路!用这种方法必须将重边去除掉! 5 6 所以推荐用dfs...
分类:
其他好文 时间:
2014-08-14 03:46:37
阅读次数:
202
1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 char map[105][105]; 7 8 int dir[8][2]={0, 1, 1, 0, -1, 0, 0, -1, 1, 1, 1, -1, -.....
分类:
其他好文 时间:
2014-08-14 01:14:27
阅读次数:
266
A Knight's JourneyTime Limit:1000MSMemory Limit:65536KTotal Submissions:30656Accepted:10498DescriptionBackgroundThe knight is getting bored of seeing ...
分类:
其他好文 时间:
2014-08-14 00:58:47
阅读次数:
307
Problem Description
Continuous Same Game is a simple game played on a grid of colored blocks. Groups of two or more connected (orthogonally, not diagonally) blocks that are the same color may be remo...
分类:
其他好文 时间:
2014-08-13 22:29:17
阅读次数:
288