Pashmak and Graph(dp + 贪心)】的更多相关文章

题目链接:Codeforces 459E Pashmak and Graph 题目大意:给定一张有向图,每条边有它的权值,要求选定一条路线,保证所经过的边权值严格递增,输出最长路径. 解题思路:将边依照权值排序,每次将同样权值的边同一时候增加,维护每一个点作为终止点的最大长度就可以. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn…
题目链接: E. Pashmak and Graph time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pashmak's homework is a problem about graphs. Although he always tries to do his homework completely, he can't sol…
http://codeforces.com/contest/459/problem/E 不明确的是我的代码为啥AC不了,我的是记录we[i]以i为结尾的点的最大权值得边,然后wa在第35  36组数据 然后參考答案了,然后----网上一份题解 大意: 给出一个带权有向图,求经过的边权绝对上升的最长路径(可能是非简单路径,就可以能经过一个点多次)所包括的边数. 题解: 对边按权值排序后,从小到大搞. 设q[x]为已经搞过的边组成的以x点为终点的最长路径包括的边数. 设当前边e[i]为从u到v的边,…
E. Pashmak and Graph time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pashmak's homework is a problem about graphs. Although he always tries to do his homework completely, he can't solve thi…
Codeforces Round #261 (Div. 2) E - Pashmak and Graph E. Pashmak and Graph time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pashmak's homework is a problem about graphs. Although he always tr…
E. Pashmak and Graph time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pashmak's homework is a problem about graphs. Although he always tries to do his homework completely, he can't solve thi…
题目描述 很久很久之前,森林里住着一群兔子.有一天,兔子们突然决定要去看樱花.兔子们所在森林里的樱花树很特殊.樱花树由n个树枝分叉点组成,编号从0到n-1,这n个分叉点由n-1个树枝连接,我们可以把它看成一个有根树结构,其中0号节点是根节点.这个树的每个节点上都会有一些樱花,其中第i个节点有c_i朵樱花.樱花树的每一个节点都有最大的载重m,对于每一个节点i,它的儿子节点的个数和i节点上樱花个数之和不能超过m,即son(i) + c_i <= m,其中son(i)表示i的儿子的个数,如果i为叶子节…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2021 题意: John要建一个奶酪塔,高度最大为m. 他有n种奶酪.第i种高度为h[i](一定是5的倍数),价值为w[i]. 一块高度>=t的奶酪被称为大奶酪,一个奶酪如果在它上方有大奶酪(多块只算一次),它的高度就会变成原来的4/5. John想让他的奶酪他价值和最大,求这个最大值. 题解: 方法一: dp + 贪心. 贪心:如果奶酪塔中有大奶酪,则大奶酪一定放在最上面. (1)有大奶…
洛谷P2507 [SCOI2008]配对 题解(dp+贪心) 标签:题解 阅读体验:https://zybuluo.com/Junlier/note/1299251 链接题目地址:洛谷P2507 [SCOI2008]配对 感觉是道很好的推断题 贪心 想到贪心的结论就很容易,没想到就很难做出来了 结论:对\(A,B\)数组分别排序之后,在\(A\)中选第\(i\)个数,与之配对的数一定在\(B[i-1]\)~\(B[i+1]\)内 其实证明是很好证的,在与你是否往这方面想了... 因为题目有一个很…
题目链接:http://codeforces.com/problemset/problem/459/E 题意: 给你一个有向图,每条边有边权. 让你找出一条路径,使得这条路径上的边权严格递增. 问你这样的路径最长有多长. 题解: 先将所有边按边权从小到大排序,以保证边权递增. 表示状态: dp[i] = max len 表示以点i为终点时的最长路径长度. 找出答案: ans = max dp[i] 如何转移: 枚举每条边e[i],则有: dp[e[i].t] = max(dp[e[i].t],…