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

建议使用的浏览器:

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

5005:Compromise

题目描述
Xiaoqiang and Amoeba (AMB for short) are good friends. Friends as they are, they are inevitably self-centered beings. So their life together is full of concession and compromise. To further promote their ongoing relationship, Xiaoqiang studies his interaction with AMB from a game theoretical perspective. He views his everyday life with AMB as a game.

The game has N "nodes" corresponding to different "states" of life. Each node has several outgoing "edges" representing "actions". A node either belongs to Xiaoqiang or AMB. The nodes and edges form a connected DAG (Directed Acyclic Graph, a graph without cycles). Each node without outgoing edges has two "utility" values for Xiaoqiang and AMB respectively.

For example, consider the following game:
● Node S: The day begins. AMB has two actions leading to A and B respectively.
● Node A: AMB goes to University P. Xiaoqiang has two actions leading to C and D respectively.
● Node B: AMB goes to University T. Xiaoqiang has two actions leading to D and E respectively.
● Node C: Xiaoqiang and AMB both go to University P. AMB's utility is 102, Xiaoqiang's utility is 99.
● Node D: Xiaoqiang and AMB go to different universities. AMB's utility is 51, Xiaoqiang's utility is 0.
● Node E: Xiaoqiang and AMB both go to University T. AMB's utility is 100, Xiaoqiang's utility is 101.

Life starts from Node S. At each node, either Xiaoqiang or AMB can take an action. Xiaoqiang's aim is to maximize his own utility (and cares nothing about AMB) and AMB's aim is also to maximize his own utility.

AMB thinks, if he goes to node A then Xiaoqiang's best response will be going to node C and he can happily live in University P with Xiaoqiang. In this case AMB's utility is 102 and Xiaoqiang's is 99. Xiaoqiang is not satisfied with this, but it seems there is nothing Xiaoqiang can do about this. This is the so called Nash Equilibrium.

Until one day Xiaoqiang claims (or, to be exact, swears): "Listen, I was attacked by a paramecium and I became insane. If I am in Node B, I will surely go to Node E. But if I am in Node A, I will go to Node D without hesitation." In this way, he reveals his whole strategy to AMB, which encodes for each node what Xiaoqiang will do if he arrives at the node. Notice that in this strategy Xiaoqiang's action (going to University T) at a node does not depend on which path is used to arrive at the node. This strategy is not rational, because at Node A Xiaoqiang's best action should be going to Node C.

But Xiaoqiang makes his claim in such a convincing voice that AMB believes that Xiaoqiang will follow this strategy at all cost however irrational it is. Then AMB finds out that his best strategy will be going to node B, and they will end up at Node E. In this case, Xiaoqiang's utility is 101. Notice that Xiaoqiang must keep his words after the claim. That is, after the claim Xiaoqiang's strategy is fixed, and AMB will make decisions to maximize his own utility provided Xiaoqiang's strategy.

Given a game, you are to determine:
(1) Xiaoqiang's best utility if he cannot make the claim.
(2) Xiaoqiagn's best utility if he can make the claim.
To make things simple, all utility values are distinct.

Remark: The real world situation is, Xiaoqiang and AMB are currently in Node D because AMB failed to get himself to University T through the entrance exam.
输入解释
The first line contains an integer T, denoting the number of the test cases.

Each test case begins with one integer N, the number of nodes. 1<=N<=200. Life starts from the first node.

Then follows N lines. Each line begins with an integer M indicating the number of actions. 0<=M<N

If M is nonzero, M integers follow. Each integer (in range [1, N]) represents the destination of an outgoing edge. At the end of the line is a character being either 'A' or 'X' describing whether this node belongs to AMB or Xiaoqiang.

If M is zero, two integers follow representing AMB's utility and Xiaoqiang's utility respectively. Utility values are in range [0, 10000] and are distinct.
输出解释
For each test case, output one line containing two integers representing the answers separated by a space.
输入样例
1
6
2 5 6 A
0 102 99
0 50 0
0 100 101
2 2 3 X
2 3 4 X
输出样例
99 101
来自杭电HDUOJ的附加信息
Recommend hujie

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

源链接: HDU-5005

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

共提交 0

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