Problem Description
Alice and Bob are playing a game on an undirected graph with n (n is even) nodes and m edges. Every node i has its own weight Wv, and every edge e has its own weight We.



They take turns to do the following operations. During each operation, either Alice or Bob can take one of the nodes from the graph that haven't been taken before. Alice goes first.



The scoring rule is: One person can get the bonus attached to a node if he/she have choosen that node before. One person can get the bonus attached to a edge if he/she have choosen both node that induced by the edge before.



You can assume Alice and Bob are intelligent enough and do operations optimally, both Alice and Bob's target is maximize their score - opponent's.



What is the final result for Alice - Bob.


 
Input
Muilticases. The first line have two numbers n and m.(1 <= n <= 105, 0<=m<=105) The next line have n numbers from W1 to Wn which Wi is the weight of node i.(|Wi|<=109)



The next m lines, each line have three numbers u, v, w,(1≤u,v≤n,|w|<=109) the first 2 numbers is the two nodes on the edge, and the last one is the weight on the edge. 
 
Output
One line the final result.


 
Sample Input
4 0
9 8 6 5
 
Sample Output
2
题意:
对于一个图。两个人轮流取点。谁取得那个点则获得那个点的价值。而一个人假设取得同一条边的两点。则同一时候也会获得这条边的价值,两人都按最优方案去取。最后输出价值之差
思路:
仅仅要将边分半给两个点就可以,假设两点同一时候在一个人身上,那么边的价值也会加上去,假设两点在两个人身上,那么边的价值会被减去
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std; #define ls 2*i
#define rs 2*i+1
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define W(a) while(a)
#define gcd(a,b) __gcd(a,b)
#define LL long long
#define N 100005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EXP 1e-8
#define rank rank1
const int mod = 10007; int n,m;
double a[N]; int main()
{
int i,j,k,x,y;
double w;
while(~scanf("%d%d",&n,&m))
{
for(i = 1; i<=n; i++)
scanf("%lf",&a[i]);
for(i = 1; i<=m; i++)
{
scanf("%d%d%lf",&x,&y,&w);
w=w/2;
a[x]+=w;
a[y]+=w;
}
sort(a+1,a+1+n);
double sum1=0,sum2=0;
for(i = 1; i<=n; i++)
{
if(i%2==0)
sum1+=a[i];
else
sum2+=a[i];
}
printf("%.0f\n",sum1-sum2);
} return 0;
}

HDU4647:Another Graph Game(贪心)的更多相关文章

  1. HDU-4647 Another Graph Game 贪心,博弈

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4647 注意这题两人的决策是想要使得自己的分数与对方的差值最大.. 注意到数据范围,显然是贪心之类的,如 ...

  2. UVA 10720 Graph Construction 贪心+优先队列

    题目链接: 题目 Graph Construction Time limit: 3.000 seconds 问题描述 Graph is a collection of edges E and vert ...

  3. 沈阳网络赛F-Fantastic Graph【贪心】or【网络流】

    "Oh, There is a bipartite graph.""Make it Fantastic." X wants to check whether a ...

  4. ACM-ICPC 2018 沈阳赛区网络预赛 F Fantastic Graph(贪心或有源汇上下界网络流)

    https://nanti.jisuanke.com/t/31447 题意 一个二分图,左边N个点,右边M个点,中间K条边,问你是否可以删掉边使得所有点的度数在[L,R]之间 分析 最大流不太会.. ...

  5. HDU 4647 Another Graph Game(贪心)

    题目链接 思路题.看的题解. #include <cstdio> #include <string> #include <cstring> #include < ...

  6. ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph (贪心或有源汇上下界网络流)

    "Oh, There is a bipartite graph.""Make it Fantastic."X wants to check whether a ...

  7. CodeForces - 459E Pashmak and Graph[贪心优化dp]

    E. Pashmak and Graph time limit per test 1 second memory limit per test 256 megabytes input standard ...

  8. Contig|scaffold|N50|L50|NG50|贪心算法|de bruiji graph|

    生物信息学 Contig是reads拼成的连续的DNA片段,连续表达一个gene.通过双端测序的contig可确定contig之间的关系得到scaffold,Scaffold是reads拼成的有gap ...

  9. AGC 043 C - Giant Graph SG函数 dp 贪心

    LINK:Giant Graph 神仙题目. 容易发现在图中选择某个点的贡献为\(10^{18\cdot(x+y+z)}\) 这等价于多选一个点多大一点就多乘了一个\(10^{18}\) 所以显然是贪 ...

随机推荐

  1. 委托delegate与Dictionary实现action选择器

    大家一定都有这种情况,1.前台页面信息是通过Ajax请求的方法加载的;2.或者是通过请求本页面加载的;3.请求的页面不仅仅是一个Http请求在 这咱情况下我们一般会加一个action的参数,用于区别是 ...

  2. JAVA向EXE文件尾追加配置信息,用于解决局版客户端的程序IP配置问题

    package com.demo.blog; import java.io.DataOutputStream;import java.io.File;import java.io.FileOutput ...

  3. Ajax不能跨域访问的解决方案

      文章介绍 这是一篇,引导文吧... 因为写这篇文章时,实在想不出该如何分序.因此以实现跨域访问为目的,从基础知识往上写.最后以百度搜索智能提示为例,来讲解跨域的具体应用! 内容 首先,我们得明确什 ...

  4. (4)PHP基本语法、变量、数据类型、运算符、流程控制

    一.基本语法 1.PHP在网页里的结构 <?php ..... ?> 2.php的另一种格式(不推荐使用) <script language="php"> ...

  5. rsync + inotify 同步

    1. 配置rysnc server:同步机,同步被同步机更新的文件,很多台vi /etc/rsyncd.conf uid=rootgid=rootuse chroot=nomax connection ...

  6. Xamarin XAML语言教程基本页面ContentPage占用面积

    Xamarin XAML语言教程基本页面ContentPage占用面积 基本页面和基本视图都是在开发应用程序时最为常用的.本章将讲解有关基本页面ContentPag.基本视图ContentView.控 ...

  7. Flash3D学习计划(三)——学习VB,IB相关,理解三角形顶点顺序;在屏幕上显示2D矩形,并实现缩放,平移,旋转

    VB:顶点缓冲 IB: 顶点索引缓冲 三角形的顶点顺序决定了三角形是顺时针还是逆时针,从而决定了三角形在背面剔除的过程中是否会被剔除掉. 相关理论知识可以在前面的文章中找到更多的说明. 实现效果 sf ...

  8. 代理模式(Proxy)--动态代理(CGLIB)

    上一篇:代理模式(Proxy)--动态代理(jdk) (1)CGLIB技术是第三方代理技术,可以对任何类生成代理,代理的原则是对目标对象进行继承代理 (2)如果目标对象被final修饰,则无法被CGL ...

  9. IntelliJ IDEA 14.x 的 project 和 module 是啥关系?

    使用基于IntelliJ的IDE,如phpstorm.android studio都会对project和module的关系比较糊涂,简单的概括如下: IntelliJ系中的 Project 相当于Ec ...

  10. 操作系统/etc/hosts文件配置

    windows对应 C:\Windows\system32\drivers\etc\hosts linux: /etc/hosts Hosts - The static table lookup fo ...