The best way to learn DP from DFS! Nice problem.My intuition is that it can be solved by DFS:class Solution {public: int climbStairs(int n) { ...
分类:
其他好文 时间:
2014-07-18 17:24:53
阅读次数:
188
油田问题,有点像图像处理里的区域生长问题,找油田块数。BFS,DFS都可以。 1 /*BFS*/ 2 #include 3 #include 4 const int maxn=100+5,maxm=1000; 5 int m,n,vis[maxn][maxn],mat[maxn][maxn],dir...
分类:
其他好文 时间:
2014-07-18 16:19:41
阅读次数:
267
这篇博文较长,且理论为主,因为我准备换种风格,以保证大家看的时候不会觉得无聊,看完如果对dfs还是一头雾水,那我也不会请你吃麻辣烫开场:刷了一遍leetcode,发现DFS是个特别强大,且出题率特别高的一个基础算法,第一次接触DFS是树的一个搜索算法,相对而言的是BFS。根据难度与考察频率参考表的建...
分类:
其他好文 时间:
2014-07-18 15:17:58
阅读次数:
242
Problem Description
可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她救出。 现据密探所报,公主被关在一个两层的迷宫里,迷宫的入口是S(0,0,0),公主的...
分类:
其他好文 时间:
2014-07-18 12:38:25
阅读次数:
249
Tempter of the BoneTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 68206Accepted Submission(s): 18...
分类:
其他好文 时间:
2014-07-18 12:09:55
阅读次数:
211
Description
Some of you may have played a game called 'Blocks'. There are n blocks in a row, each box has a color. Here is an example: Gold, Silver, Silver, Silver, Silver, Bronze, Bronze, Bronze, Go...
分类:
其他好文 时间:
2014-07-18 11:23:05
阅读次数:
280
Given a binary tree containing digits from 0-9 only,
each root-to-leaf path could represent a number.
An example is the root-to-leaf path 1->2->3 which represents
the number 123.
Find the to...
分类:
其他好文 时间:
2014-07-18 11:13:57
阅读次数:
204
可以转化为着色模型dfs + 四色定理 1 #include 2 #include 3 int n,num; 4 int d[100][100]; 5 int c[100]; 6 7 bool ok(int step) 8 { 9 for(int i = 0; i = n) return ...
分类:
其他好文 时间:
2014-07-18 10:18:34
阅读次数:
239
Children of the Candy Corn
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 9311
Accepted: 4039
Description
The cornfield maze is a popular Hallowee...
分类:
其他好文 时间:
2014-07-17 21:09:46
阅读次数:
319
迷宫的最短路径 代码(C++)本文地址: http://blog.csdn.net/caroline_wendy题目: 给定一个大小为N*M的迷宫. 迷宫由通道和墙壁组成, 每一步可以向邻接的上下左右四格的通道移动.请求出从起点到终点所需的最小步数. 请注意, 本题假定从起点一定可以移动到终点.使用宽度优先搜索算法(DFS), 依次遍历迷宫的四个方向, 当有可以走且未走过的方向时, 移动并且步数加...
分类:
编程语言 时间:
2014-07-17 21:02:38
阅读次数:
323