CodeForces 615B Longtail Hedgehog】的更多相关文章

题目: http://codeforces.com/problemset/problem/615/B 题意:题目描述很复杂,但实际上很简单.大意就是连续的几个点组成尾巴,要求尾巴的长度乘以尾巴终点的分支数的最大值,其中尾巴要满足的条件是有边相连,且尾巴上节点的编号一定是递增的,终点是最大值. 我刚开始的想法是,先用邻接表保存这个无向图(矩阵保存不了),在读取边的时候,用一个数组保存每个节点的分支数,然后用深搜,遍历尾巴的最大长度,同时每扩展一个点,用当前长度乘以该点的分支数,并不断更新这个最大值…
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…
题目链接: codeforces 615 B. Longtail Hedgehog (DFS + 剪枝) 题目描述: 给定n个点m条无向边的图,设一条节点递增的链末尾节点为u,链上点的个数为P,则该链的beauty值 = P*degree[u].问你所有链中最大的beauty值. 解题思路: 因为只需要找到以每个节点为终点的最长递增链即可,所以建图的时候可以建成从编号小的节点到编号大的节点的有向图,然后用DFS搜索,但是直接暴搜会TLE,然后就开始了我的TLE之路,TLE24, TLE42,TL…
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…
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…
题目链接: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性质…
水 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);…
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. Meeting of Old Friends time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya! Sony…