poj2152 Fire】的更多相关文章

好难啊,我弱爆了. 题解看陈启峰的论文... /** * Problem:POJ2152 * Author:Shun Yao * Time:2013.9.2 * Result:Accepted * Memo:TreeDP */ #include <cstring> #include <cstdio> #include <climits> #define MAXN 1010 #define inf LONG_MAX long n, w[MAXN], d[MAXN], f[…
题目链接 POJ2152 题解 经典老题,还真暴力 \(n \le 1000\),所以可以\(O(n^2)\)做 所以可以枚举每个点依附于哪一个点 设\(f[u]\)表示以\(u\)为根的子树的最小代价 \(g[u][v]\)表示\(u\)依附于\(v\)时以\(u\)为根的子树的最小代价 显然 \[f[u] = min\{ g[u][v] \}\] \[g[u][v] = cost[v] + \sum\limits_{(u,to) \in edge} min(g[to][v] - cost[v…
题目链接:https://vjudge.net/problem/POJ-2152 题意:给定一颗大小为n的树,在每个结点建消防站花费为w[i],如果某结点没有消防站,只要在它距离<=d[i]的结点有消防站即可,求最小花费. 思路: 好难的树形dp,一点思绪也木有,只能搜题解. 用dp[u][i]表示以u为根的子树满足条件,并且结点u依赖于结点i的最小花费.用best[u]表示以u根的子树满足条件的最小花费,那么best[u]=min(dp[u][i]). 求best[u]时,先跑一遍dfs得到所…
题目大意:在一棵树中选出一些点,选每个点的代价为w(i),并且对于点 i ,在距离它lim(i)之内必须选一个点,使它作为 i 的依赖点.求最小代价. 题目分析:定义状态dp(u,k)表示使u为根节点的子树满足题意并且节点u依赖节点k产生的最小代价,定义best(u)表示子树u满足题意得最小代价.则状态转移方程为: dp(u,k)=w(k)+∑min(dp(v,k)-w(k),best(v)) dist(u,k)<=lim(u) dp(u,k)=oo dist(u,k)>lim(u) best…
题意:n个城市n-1条边 组成一棵树 在每个城市修建消防站会有一个花费costi 每个城市能防火当且仅当地图上距离他最近的消防站距离小于di   问如何修建消防站 使地图上所有的城市都有预防火灾的能力 题解: 这个题太难了..... 完全不会 具体来说就是用dp[i][j]表示在处理i这个城市的时候在j城市修消防站 如果dis i,j > di 那么表示这样修不合法就让dp[i][j] = INF 如果合法这样就已经确定了两个状态 那么我们同样采用先递归再回溯更新的方法 用ans[i]表示包含i…
题目大意:有一棵$n$个点的带边权树,第$i$个点有两个值$w_i,d_i$,表示在这个点做标记的代价为$w_i$,且这个点距离$d_i$以内至少要有一个点被标记,为最小代价.$n\leqslant6000$ 题解:记$f[i][j]$表示以$i$为根的子树全部满足条件,且第$i$个点是由于$j$被标记导致的,$g[i]$表示以$i$为根的子树全部满足条件的代价.$f[i][j]=w_i+\min\limits_{v\in son[u]}\{f[v][j]-w_i,g[v]\}$ 卡点:无 C+…
题目大意:给定一棵 N 个节点的无根树,点有点权,边有边权,现需要选出一个点集,满足树上任意一个点到该点集的距离不超过该点的给定值,求选出点集点权的最小值是多少. 题解:可以发现,对于以 i 为根的子树来说,i 点依赖的点很有可能并不是 i 内部的节点,转移比较麻烦.考虑开两个数组 f[], g[][],分别表示以 i 为根的子树满足上述条件的最小权值和以 i 为根的子树中,i 号节点依附于 j 号节点的情况下的最小权值.每次子树向父节点进行转移时,考虑枚举每个依附点,用子树的 f 和 g 去更…
POJ 2152 fire / SCU 2977 fire(树型动态规划) Description Country Z has N cities, which are numbered from 1 to N. Cities are connected by highways, and there is exact one path between two different cities. Recently country Z often caught fire, so the governm…
fire poj-2152 题目大意:给出一颗树,给出两个相邻节点的距离,以及每个节点的接受范围,还有当前节点的代价.我们想要求出覆盖整个图的最小代价. 注释:一个点被覆盖,当且仅当该点有防火站或者这个点的接受范围之内有防火站.计算两个不相邻节点的距离用LCA计算.节点数<=1000,接受范围<=10,000. 想法:poj最后一道树形dp,用这道神一样的树形dp结尾,在好不过. 对于一个节点来讲设几个状态:ans[pos]表示使以pos为根的子树被保护的最小代价.dp[pos][save]表…
在论文<SQUEEZENET: ALEXNET-LEVEL ACCURACY WITH 50X FEWER PARAMETERS AND <0.5MB MODEL SIZE>中,作者对模型进行压缩的核心我感觉就是利用许多的Fire Module模块来替代原来的conv+pool 其中所谓的"Fire Module"就是一种专门设计的结构,具体而言是由两部分构成:sequeeze以及后面连接的enpand两部分,其中的sequeeze部分是卷积核为1*1的卷积层,后面的…
Fire Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice FZU 2150 Description Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning,…
Fire 分析: 首先,明确题意:b1,b2,--,bn 交换为b2,--,bn,b1,但这并不是意味着只能从b1开始交换,(这点从样例中可以看出),并且也不意味着交换的必须是连续的一串,可以是几个单点,如: 原序列:1 2 3 4 5,交换(1 3 5)后 新序列:3 2 5 4 1 交换时必须按照环的方式顺时针或逆时针转动,这并没有限制,只需要一个位置移动到另一个位置时将他顶替掉,他去找他自己应该到的位置就好了,最终是按一个环的移动方式移动,但不一定是从左到右或从右到左,方向交叉. 所以:…
Fire Eye是一款轻量级简单易用的Android校验库. FireEye 2.0 在 1.0 的基础上,全部重写了代码,并优化了架构,性能上和逻辑上都大大提升.只需要几行代码,即可验证用户输入,并且将验证错误反馈给用户.它内置了大量常用的验证类型,足以满足你的功能需求. Gradle 依赖 Add dependency dependencies { compile 'com.github.yoojia:fire-eye:2.2@aar' } Maven <dependency> <g…
FZU 2150 Fire Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Description Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, each grid of this bo…
题目大意:在一个N*M的迷宫内,J代表某人(只有一个),F代表火(可能不只一个),#代表墙,火每分钟会向四周除了墙以外的地方扩散一层,问人能否在没被火烧到 之前逃出迷宫,若能逃出输出最短时间.很明显的bfs.但由于火到达的地方人不能抵达,故需先对火进行bfs,标记后若人在火烧到之前抵达即可.最后逃出时间需要加一, 因为当时只是抵达边界,若逃出时间需加一. #include <stdio.h> #include <queue> #include <string.h> #i…
在上周Amazon也耐不住加入了手机竞争行列之中,发布了自己的Fire Phone,于是Android家族又多了一位变种成员,Android系统的碎片化程度也进一步加剧.因为工作的关系,我有幸在上个月就得到了一部工程机为其做提前开发,不过因为政策原因所以到现在才能来谈谈对这部新手机的看法. 对于Fire Phone的功能以及外观,官方网站和各家技术网站都有了详尽的介绍和报道,再者因为我拿到的是工程机,无法体现到完备的功能展现,因此本篇文章谈的主要是Fire Phone对于开发者而言所要面对的问题…
Fire! Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Description   Problem B: Fire! Joe works in a maze. Unfortunately, portions of the maze have caught on fire, and the owner of the maze neglected to create a fi…
Problem 2150 Fire Game Accept: 145    Submit: 542 Time Limit: 1000 mSec    Memory Limit : 32768 KB Problem Description Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, each grid o…
Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5863    Accepted Submission(s): 3280 Problem Description Suppose that we have a square city with straight streets. A map of a city is a s…
题目传送门 /* 题意:在一个矩阵里放炮台,满足行列最多只有一个炮台,除非有墙(X)相隔,问最多能放多少个炮台 搜索(DFS):数据小,4 * 4可以用DFS,从(0,0)开始出发,往(n-1,n-1)左下角走,x = cnt / n; y = cnt % n; 更新坐标, 直到所有点走完为止,因为从左边走到右边,只要判断当前点左上方是否满足条件就可以了 注意:当前点不能放炮台的情况也要考虑 g[x][y] == 'o'; 的错误半天才检查出来:) */ #include <cstdio> #…
Fire! Time Limit: 5000MS   Memory Limit: 262144KB   64bit IO Format: %lld & %llu Description Joe works in a maze. Unfortunately, portions of the maze have caught on fire, and the owner of the maze neglected to create a fire escape plan. Help Joe esca…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8185    Accepted Submission(s): 4691 Problem Description Suppose that we have a squa…
Description: You are trapped in a building consisting of open spaces and walls. Some places are on fire and you have to run for the exit. Will you make it?At each second, the fire will spread to all open spaces directly connected to the North, South,…
http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1045 Description Suppose that we have a square city with straight streets. A map of a city…
题目链接 http://vjudge.net/contest/121377#problem/J Joe works in a maze. Unfortunately, portions of the maze have caught on fire, and the owner of the maze neglected to create a fire escape plan. Help Joe escape the maze. Given Joe's location in the maze…
题目:Hire and Fire 题目翻译成数据结构就是:建树,加结点,删除结点,打印结点.只有删除结点稍微复杂点,因为删除设计掉树的调整. 首先要考虑树怎么存储才能使解题更顺手. 1.我们要存储每个结点的孩子,父亲和名字.存储孩子是因为第一个孩子可能会“升级”,存储父亲是因为要打印,名字肯定也是要打印的: 2.我们要知道每个结点的子树,删除结点会涉及调整: 3.我们要知道根节点,存放CEO. 所以我们的结点出来了,如下: struct Tman { string name; Tman *fat…
Building Fire Stations Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3820 Description Marjar University is a beautiful and peaceful place. There are N buildings and N - 1 bidirectional roads…
Fire Net Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 10   Accepted Submission(s) : 3 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Suppose that we have a square…
Fire   Description Country Z has N cities, which are numbered from 1 to N. Cities are connected by highways, and there is exact one path between two different cities. Recently country Z often caught fire, so the government decided to build some fireh…
http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6756    Accepted Submission(s): 3829 Problem Description Suppose that we have a square ci…