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

建议使用的浏览器:

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

3942:Everyone Has His Wing Broken

Special Judge 特殊评判
题目描述
Long long ago, N gamblers (numbered from 1 to N) got together to gamble. At that time, the kinds of gamble were not that much diversified. The gamble can only be performed in a way that two people played against each other and the one who lost the game would have to give the winner $1. Furthermore, the one who lose all his money and lose for another time would get out and never come back. But he still has to pay $1 (He may sell his pants). After playing for quite a long time, they felt as if they had their wings broken, for everyone still here won nothing.
As one of the gamblers, mzry1992 wondered what really happened. Now mzry1992 wants you to tell him what happened between some pairs, for example how much does gambler A win from gambler B directly. But actually you do not know the real situation. So you could just tell him one of the possible situations.
输入解释
There are T cases and the first line of the input contains the number T. The first line of each case consists of one integer N(2 ≤N≤500), indicating the number of gamblers. Then comes N lines. The i-th line is a non-negative integer smaller than 101 indicating the i-th gambler's initial possess. The next line contains one integer M(0≤M≤10000), indicating the number of pairs of gamblers who gambled. The following M line contains three integer A, B, t(1≤A, B≤N, 1≤t≤100), which means that the gamble A and the gamble B played the game for t times. The final part of each test case begins with an integer Q (1≤Q≤200000). Then Q lines follows. Each line contains two integers A, B. You are asked to answer how much gambler A wins from B.
输出解释
Output the all the queries from mzry1992.For each test case, your answer should assume that all of the gambles could happen in the one situation. If there is no such situation, just output “Impossible!.
输入样例
3
3
7
5
9
3
1 2 7
1 3 5
2 3 9
1
1 2

3
1
1
20
1
1 2 2
2
1 2
1 3

3
1
1
20
1
1 2 3
2
1 2
1 3
输出样例
Case 1:
-5
Case 2:
0
0
Case 3:
Impossible!

提示
The gambles do not have to happen in the given order.
来自杭电HDUOJ的附加信息
Author Sakuya
Recommend xubiao

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

源链接: HDU-3942

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

共提交 0

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