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

建议使用的浏览器:

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

6002:Game Leader

题目描述
Recently Tom is playing an interesting game. The game contains a social network, so players can make friends with each other. The friend relation is symmetric, which means if A is a friend of B, B is also a friend of A.
Players’ ratings are distinct from each other, which means there are no two players sharing a same rating. Each player owns a ranklist containing all his friends’ rating (including himself) and there is one leader who has the highest rating in each player’s ranklist.
Tom has N friends. During the communications with these friends, he knows some pairs of friends are also friends. But he doesn’t know all the such pairs. In other words, some friends maybe are friends but Tom doesn’t know it.
One day, Tom noticed that the system started showing the number of leaders for every friend.
E.g. the system may says Peter is leader on 3 players’ ranklist.
Now Tom can see the number of leaders for every friend. He would like to know the least number of strangers’ ranklist leader are his friends.
输入解释
The first line of the input gives the number of test cases, T. T test cases follow. Each test case starts with a line consists of 3 integers, N, M and R representing the number of people on Tom’s ranklist(including Tom), the number of friendships Tom knows and the rank of Tom in his ranklist(1-indexed). The next line consists of N integers, the $i^{th}$ integer $C_i$ represents the number of leaders for the friend on rank i. The following M lines each consists of 2 integers $X_i$ , $Y_i$ , means that the friend on rank $X_i$ is a friend of friend on rank $Y_i$.
输出解释
For each test case, output one line containing “Case #x: y”, where x is the test case number (starting from 1) and y is the least number of ranklists that not owned by Tom’s friend but the leader is Tom’s friend.

limits


$\bullet 1 ≤ T ≤ 100.$
$\bullet 1 ≤ N, M ≤ 10^5.$
$\bullet 1 ≤ X_i ≤ N.$
$\bullet 1 ≤ Y_i ≤ N.$
$\bullet 1 ≤ R ≤ N.$
$\bullet R \neq X_i .$
$\bullet R \neq Y_i .$
$\bullet X_i \neq Y_i .$
$\bullet 0 ≤ C_i ≤ 10^9.$
$\bullet$ It’s guaranteed that the data is valid.

输入样例
2
4 0 3
1 0 0 2
4 1 4
1 0 2 0
1 3
输出样例
Case #1: 2
Case #2: 2
来自杭电HDUOJ的附加信息
Recommend jiangzijing2015

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

题目来源 2016 CCPC-Final

源链接: HDU-6002

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

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 32768/32768K(Java/Others)