当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6832:A Very Easy Graph Problem

题目描述
An undirected connected graph has $n$ nodes and $m$ edges, The $i$-th edge’s length is $2^i$. Each node $i$ has a value $a_i$, which is either $0$ or $1$. You need to calculate:

$$
\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$.
输入解释
The 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$.
输出解释
Print a single integer—— the value of the answer modulo $10^9+7$.
输入样例
1
3 2
0 1 0 
3 1
3 2
输出样例
10
来自杭电HDUOJ的附加信息
Recommend IceyWang

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6832

最后修改于 2020-10-25T23:34:46+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000/2500MS(Java/Others) 65536/65536K(Java/Others)