编程介的小学生 2019-08-26 21:57 采纳率: 20.5%
浏览 146

Everyone Has His Wing Broken的解答

Problem Description
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,theonewholoseallhismoneyandloseforanothertimewouldgetoutandnevercomeback.Buthestillhastopay1 (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.

Input
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
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!.

Sample Input
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

Sample Output
Case 1:
-5
Case 2:
0
0
Case 3:
Impossible!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置