hdu 4647 Another Graph Game】的更多相关文章

题意: 有N个点,M条边. 点有权值, 边有权值. Alice, Bob 分别选点. 如果一条边的两个顶点被同一个人选了, 那么能获得该权值.问 Alice - Bob? 链接:http://acm.hdu.edu.cn/showproblem.php?pid=4647 思路: 贪心. 对于一条边来说, 如果拿了一个点, 说明已经拿了该边的一半权值. 如果某边的两个的顶点分别是不同的人.  那么差值还是不变的.  如果某边的两个顶点分别是同一个人. 那么和值也不变. 所以我们可以把一个边分解到两…
摘自题解: 若没有边权,则对点权从大到小排序即可.. 考虑边,将边权拆成两半加到它所关联的两个点的点权中即可. ..因为当两个人分别选择不同的点时,这一权值将互相抵消. 代码如下: #include <cstdio> #include <cstring> #include <algorithm> #define LL long long #define INF 0x7fffffff #define M 100010 using namespace std; int co…
题目链接 思路题.看的题解. #include <cstdio> #include <string> #include <cstring> #include <algorithm> using namespace std; #define LL __int64 LL p[]; int main() { int i,n,m,sv,ev,w; while(scanf("%d%d",&n,&m)!=EOF) { memset(p…
官方题解: 若没有边权,则对点权从大到小排序即可.. 考虑边,将边权拆成两半加到它所关联的两个点的点权中即可. ..因为当两个人分别选择不同的点时,这一权值将互相抵消. #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> using namespace std; ; int N, M; double node[MAXN]; int main() { whil…
解题思路:若没有边权,则对点权从大到小排序即可.. 考虑边,将边权拆成两半加到它所关联的两个点的点权中即可. ..因为当两个人分别选择不同的点时,这一权值将互相抵消. 以上摘自杭电的解题报告. 至于为什么,还想得不是很清楚···· 由于在处理时使用的是整数,整数/2,当为奇数时0.5就不见了,所以直接把点的权值翻倍,最后结果除以2,这算是一个技巧吧···· 贴代码: #include <cstdio> #include <algorithm> #define N 100005 us…
题目是给一个无向图,其中每个节点都有点权,边也有边权,然后就有2个小朋友开始做游戏了ALICE &BOB 游戏规定ALICE 先行动然后是BOB,然后依次轮流行动,行动时可以任意选取一个节点并获得节点的点权,如果他已经把一条边的2个端点都取了,那么他可以获得那边的边权,如果一条边的二个端点不同的人取了,那么谁也得不到那条变得边权了. 问游戏结束后怎样可以使ALICE得到的权值和减去BOB 的权值和最大,当然二个人都一样足够聪明,即每次行动都会采取最优的策略 解法若没有边权,则对点权从大到小排序即…
HDU 6321 Dynamic Graph Matching (状压DP) Problem C. Dynamic Graph Matching Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 1796 Accepted Submission(s): 731 Problem Description In the mathematical…
Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 689    Accepted Submission(s): 238 Problem Description In graph theory, the complement of a graph G is a graph H on the same vertic…
Sparse Graph Problem Description   In graph theory, the complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if and only if they are notadjacent in G. Now you are given an undirected graph G of N…
Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1520    Accepted Submission(s): 537 Problem Description In graph theory, the complement of a graph G is a graph H on the same verti…