CodeForces615B-Longtail Hedgehog-dp/图】的更多相关文章

B. Longtail Hedgehog 题目连接: http://www.codeforces.com/contest/615/problem/B Description This Christmas Santa gave Masha a magic picture and a pencil. The picture consists of n points connected by m segments (they might cross in any way, that doesn't m…
Longtail Hedgehog time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output This Christmas Santa gave Masha a magic picture and a pencil. The picture consists of n points connected by m segments (th…
B. Longtail Hedgehog   This Christmas Santa gave Masha a magic picture and a pencil. The picture consists of n points connected by m segments (they might cross in any way, that doesn't matter). No two segments connect the same pair of points, and no…
题目链接: codeforces 615 B. Longtail Hedgehog (DFS + 剪枝) 题目描述: 给定n个点m条无向边的图,设一条节点递增的链末尾节点为u,链上点的个数为P,则该链的beauty值 = P*degree[u].问你所有链中最大的beauty值. 解题思路: 因为只需要找到以每个节点为终点的最长递增链即可,所以建图的时候可以建成从编号小的节点到编号大的节点的有向图,然后用DFS搜索,但是直接暴搜会TLE,然后就开始了我的TLE之路,TLE24, TLE42,TL…
题目链接:http://codeforces.com/problemset/problem/615/B 题目意思:要画一只 hedgehog,由 tail 和 spines 组成.我们要求得 beauty 最大值: tail * spines. 以下摘自 udon 原话,大家细细品味:(不一定是正确无误的哦,可能有误导他人成分...) 1.对于所有点 x,求出 x 的度数 d[x],O(n+m) 2.对于所有点 x,求出以点 x 为结尾的最长链长度 l[x],由于尾巴节点要求递增,符合DAG性质…
http://acm.hdu.edu.cn/showproblem.php?pid=5001 当时一看是图上的就跪了 不敢写,也没退出来DP方程 感觉区域赛的题  一则有一个点难以想到 二则就是编码有点难度. 这个题: 我一直的思路就是1-能到达i的概率 就是不能到达i的概率.然后三维方程巴拉巴拉,,,,把自己搞迷糊 正确做法: dp[k][j]   经过j步到达k点 而且不经过i点的概率 这么设的原因是.就能够求不能到达i点的概率了.   不能到达i点的概率就是segma(dp[v][j-1]…
题目: http://codeforces.com/problemset/problem/615/B 题意:题目描述很复杂,但实际上很简单.大意就是连续的几个点组成尾巴,要求尾巴的长度乘以尾巴终点的分支数的最大值,其中尾巴要满足的条件是有边相连,且尾巴上节点的编号一定是递增的,终点是最大值. 我刚开始的想法是,先用邻接表保存这个无向图(矩阵保存不了),在读取边的时候,用一个数组保存每个节点的分支数,然后用深搜,遍历尾巴的最大长度,同时每扩展一个点,用当前长度乘以该点的分支数,并不断更新这个最大值…
B. Longtail Hedgehog time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output This Christmas Santa gave Masha a magic picture and a pencil. The picture consists of n points connected by m segments…
 B. Longtail Hedgehog time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output This Christmas Santa gave Masha a magic picture and a pencil. The picture consists ofn points connected by m segment…
水 A- Bulbs #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 5; const int INF = 0x3f3f3f3f; bool vis[110]; int main(void) { memset (vis, false, sizeof (vis)); int n, m; scanf ("%d%d", &n, &m);…