POJ 2607 Fire Station】的更多相关文章

题目链接: http://poj.org/problem?id=2607 Description A city is served by a number of fire stations. Some residents have complained that the distance from their houses to the nearest station is too far, so a new station is to be built. You are to choose t…
Fire Station Time Limit: 5000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: 260764-bit integer IO format: %lld      Java class name: Main   A city is served by a number of fire stations. Some residents have complained that…
描述A city is served by a number of fire stations. Some residents have complained that the distance from their houses to the nearest station is too far, so a new station is to be built. You are to choose the location of the fire station so as to reduce…
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…
一次FLOYD,再枚举. 注意题目要求的输出是什么哦. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ; ; int maze[MAXN][MAXN]; bool house[MAXN]; int dis[MAXN],fire,n; int main(){ int u,v,w; while(scanf(&qu…
Description Roger Wilco is in charge of the design of a low orbiting space station for the planet Mars. To simplify construction, the station is made up of a series of Airtight Cubical Modules (ACM's), which are connected together once in space. One…
题意:一棵有n个结点的树,要取其中的一个结点,使得该结点到其他所有结点的距离和dis最小,即损耗I * I * R * dis最小,输出最小损耗和该结点(有多个的话按结点编号从小到大输出)(3 <= n <= 50000, 1 <= I <= 10, 1 <= R <= 50). 题目链接:http://poj.org/problem?id=4045 ——>>怒刷树状dp... 设cnt[i]为以i为根的子树的结点数,d[i]为以i为根的子树中所有结点到i的…
http://poj.org/problem?id=2152 题意: n个节点组成的树,要在树一些点上建立消防站,每个点建站都有个cost[i],每个点如果不在当前的点上建站,也要依赖其他的消防站,并且距离不超过limit[i].求符合上述条件的最小费用建站费用. 思路: 感觉有点无从下手,如果不会的话可以先看一下一张一弛,解题之道这篇论文. 其实说白了,就是暴力枚举. 先设立一个辅助数组$best$,$best[u]$表示以u及其子树的最小费用,$dp[u][j]$表示u依赖j节点时(也就是j…
题意: 思路:令F[i][j]表示 的最小费用.Best[i]表示以i为根节点的子树多有节点都找到负责消防站的最小费用. 好难的题... #include<algorithm> #include<cstdio> #include<cmath> #include<cstring> #include<iostream> ],first[],next[],val[]; ],f[][]; ],d[],best[]; void insert(int x,i…
算是我的第一个树形DP 的题: 题目意思:N个城市形成树状结构.现在建立一些消防站在某些城市:每个城市有两个树形cost(在这个城市建立消防站的花费),limit : 我们要是每个城镇都是安全的:就是每个距离这个城镇最近的消防站不能超过这个城镇的limit值: 解法:这个题目乍一看卧槽怎么玩!玩不了啊!先给出dp[i][j]( I 依靠J,并且 I 这课子树都已经被覆盖的最优解(不一定都被J覆盖)): 假设一个节点的亲儿子树都被解决完毕,我们对于这些 亲儿子树 和这个 节点所组成的树的解如何得出…