F - A Very Easy Graph Problem HDU - 6832 未解决
$$
\sum_{i=1}^{n}\sum_{j=1}^{n}d(i,j)\times [a_i=1\wedge a_j=0]
$$
$d(i,j)$ indicates the shortest distance between $i$ and $j$. $[\ ]$ is the Iverson bracket. $\wedge$ indicates $\texttt{AND}$.
Because the answer may be too large, please output the answer modulo $10^9 + 7$.
InputThe first line contains one integer $T$($1\le T \le 8$),indicating the number of test cases.
The second line contains two ingeters $n,m$($1\le n\le 10^5,1\le m\le 2\times 10^5$).
The third line contains $n$ positive integers $a_1,a_2,...,a_n(a_i = 0$ or $1$) —— the value of the nodes.
The following $m$ lines contain two ingeters $u,v(1
\le u,v \le n)$, and the $i$-th line represents the i-th undirected edge’s length is $2^i$, between node $u$ and $v$.
The sum of $n,m$ is no more than $2\times 10^5$.OutputPrint a single integer—— the value of the answer modulo $10^9+7$.Sample Input
1
3 2
0 1 0
3 1
3 2
Sample Output
10
Sponsor
题意:
给出一个无向连通图,里面的点分为0号点和1号点,第i条边的边权是2的i次。
询问所有1号点到0号点的最短路径之和。
题解:
建树,最短路径都在图的最小生成树上
统计单边的贡献:
一边跑一边计数 乘上边权值
附代码(未通过,待解决)
F - A Very Easy Graph Problem HDU - 6832 未解决的更多相关文章
- hdu 6832 A Very Easy Graph Problem 构造树+dfs
题意: 给你一个n个点m条边的图,对于第i条边,它的长度是2i,对于每一个顶点,它不是0类型,就是1类型.你需要找出来对于所有的"两个不同类型的点之间最短距离"的和 题解(参考:h ...
- HDU 5572 An Easy Physics Problem (计算几何+对称点模板)
HDU 5572 An Easy Physics Problem (计算几何) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5572 Descripti ...
- HDU 5572--An Easy Physics Problem(射线和圆的交点)
An Easy Physics Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/ ...
- hdu 5572 An Easy Physics Problem 圆+直线
An Easy Physics Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/ ...
- UVA11069 - A Graph Problem(DP)
UVA11069 - A Graph Problem(DP) 题目链接 题目大意:给你n个点.要你找出有多少子串符合要求.首先没有连续的数字,其次不能再往里面加入不论什么的数字而不违反第一条要求. 解 ...
- Flow Problem HDU - 3549
Flow Problem HDU - 3549 Network flow is a well-known difficult problem for ACMers. Given a graph, yo ...
- D - Ugly Problem HDU - 5920
D - Ugly Problem HDU - 5920 Everyone hates ugly problems. You are given a positive integer. You must ...
- Prime Ring Problem HDU - 1016 (dfs)
Prime Ring Problem HDU - 1016 A ring is compose of n circles as shown in diagram. Put natural number ...
- 【HDU 5572 An Easy Physics Problem】计算几何基础
2015上海区域赛现场赛第5题. 题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5572 题意:在平面上,已知圆(O, R),点B.A(均在圆外),向量 ...
- HDU - 5572 An Easy Physics Problem (计算几何模板)
[题目概述] On an infinite smooth table, there's a big round fixed cylinder and a little ball whose volum ...
随机推荐
- L1-1、Prompt 是什么?为什么它能“控制 AI”?
*--Prompt 入门 L1-1 想象一下,你只需输入一句话,AI 就能自动为你写一篇文案.生成一份报告.甚至规划你的创业计划.这种"对话即编程"的背后魔法,就是 Prompt ...
- Spring 注解之 @MapperScan 和 @Mapper
@Mapper注解 为了让别的类能够引用UserMapper,需要在UserMapper类上添加@Mapper注解: @Mapper public interface UserMapper { pub ...
- openssl头文件出现DEPRECATEDIN_1_1_0导致引入头文件时程序无法编译
我使用的是unbuntu20.04版本中,通过apt安装的openssl,发现openssl中的多个库文件中会出现类似'DEPRECATEDIN_1_1_0(unsigned char *ASN1_S ...
- 全球首个无限执行的 AI 出现!给我玩爽了
给 AI 一句话,它就能自主执行任务,生成复杂的大型网站.几十页的 PPT.万字爆款图文.千万字长篇小说? 据说这是世界上第一款无限的 AI 智能体 -- Flowith. 无限这个词听起来有点东西啊 ...
- k8s events说明
简单说明 k8s的Event事件是一种资源对象,用于展示集群内发生的情况,k8s系统中的各个组件会将运行时发生的各种事件上报给apiserver . 可以通过kubectl get event 或 k ...
- 玩转集群配置中心,一文带你了解 Taier 控制台
原文地址:玩转集群配置中心,一文带你了解Taier控制台丨DTMO 03期直播回顾(内含视频+课件) 课程视频回顾:Taier基础教程(二):Taier1.1新功能详解&控制台介绍_哔哩哔 ...
- java类型转换的例子
Java中数据类型自动转换优先级 犹由于java是强类型语言,所以进行一些运算的时候,必须进行类型转换运行中不同类型数据先转为同一类型再进行运算 /*注意点:1.不能对布尔值进行转换2.不能把对象类型 ...
- C# WinFrom 中程序完全退出,终止
https://wenku.baidu.com/view/621fbbec0066f5335b81218f.html 一.关闭窗体在c#中退出WinForm 程序包括有很多方法, 如:this.Clo ...
- js对象生成ts类型声明
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- java slider
简介 简单 code /* * @Author: your name * @Date: 2020-11-05 10:21:52 * @LastEditTime: 2020-11-05 10:45:16 ...