ZOJ(ZJU) 1002 Fire Net(深搜)】的更多相关文章

Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A blockhouse is a small castle that has four openings through which to shoot. The fo…
ZOJ Problem Set - 1002 Fire Net Time Limit: 2 Seconds      Memory Limit: 65536 KB Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A…
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=85 http://poj.org/problem?id=1130 这两个题只有输入输出形式不一样.ZOJ的麻烦一点,这里用的ZOJ的输入输出方式 解题报告: 1.输入方式sscanf(line,"%d%d",&a,&b);表示在文本line中提取两个整形数据到a,b中 2.从外星人的角度来看,就是搜索单源最短路径,采用的方式是广搜. 3.删…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=2 解题报告: 这里的深搜有一点不同,就是,在深搜每一个点时,都要深搜每一个点,就是一个完全二叉树. 借鉴:http://blog.csdn.net/zxy_snow/article/details/5952668 #include <stdio.h> #include <iostream> #include <stdlib.h> using…
细节问题各种虐!! 其实就是简单的一个深搜 看成二叉树来理解:每个节点有两个枝:入栈和出栈. 剪枝操作:只有当栈顶元素和当前位置的目标字符相同时才出栈,否则就不出栈 dfs写三个参数:depth搜索深度,npush压栈数,npop出栈数 npush用于记录压栈数:主要判断当前压栈是否合理,以及要压入的元素在原串种的位置 npop用于记录出栈数:判断生成的目标串元素的位置 当npush==npop==目标串时,说明生成了一个可执行的操作串 注意输出操作串的时候一定要用depth参数来控制,因为在多…
题目链接:HDU 5355 http://acm.split.hdu.edu.cn/showproblem.php?pid=5355 Problem Description There are m soda and today is their birthday. The 1-st soda has prepared n cakes with size 1,2,…,n. Now 1-st soda wants to divide the cakes into m parts so that th…
题目链接:zoj 3820 Building Fire Stations 题目大意:给定一棵树.选取两个建立加油站,问说全部点距离加油站距离的最大值的最小值是多少,而且随意输出一种建立加油站的方式. 解题思路:二分距离推断,推断函数的复杂度是o(n),这种复杂度应该是o(nlogn).即使常数系数偏大,可是竟然跑了4.5s,也是醉了. 推断函数里面做了3次bfs,可是每次bfs节点最多遍历1次,首先任取一点做根建立一个树,找到深度最大的节点.以向上移动L(推断的ans)位置处的节点建立加油站,并…
这个题我看了,都是推荐的神马双向广搜,难道这个深搜你们都木有发现?还是特意留个机会给我装逼? Open the Lock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3014    Accepted Submission(s): 1323 Problem Description Now an emergent task for you…
利用TreeView控件加载文件,必须遍历处所有的文件和文件夹. 深搜算法用到了递归. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows…
题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52310 problem description Define the depth of a node in a rooted tree by applying the following rules recursively: • The depth of a root node is 0. • The depths of child nodes whose parents are with…