#P2474. [SCOI2008] 天平

    ID: 1486 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2008四川各省省选状态压缩,状压差分约束期望

[SCOI2008] 天平

Description

You have nn weights, each of which is 11 gram, 22 grams, or 33 grams. You do not know the exact mass of each weight, but you know some pairwise weight comparisons. You place two weights AA and BB on the left pan of a balance scale, and you need to choose two other weights to place on the right pan. How many unordered choices are there that make the left pan heavier (c1c_1), balance (c2c_2), or the right pan heavier (c3c_3)? (Only count choices for which the outcome is uniquely determined.) The choice is unordered; that is, choosing weights 11 and 22 is the same as choosing 22 and 11.

Input Format

The first line contains three positive integers n,A,Bn,A,B (1A,Bn,AB1\le A,B\le n,A\neq B).

The following nn lines contain the weight relation matrix. In row ii, the jj-th character is a plus + if weight ii is heavier than weight jj, a minus - if weight ii is lighter than weight jj, an equals = if weight ii and weight jj are equal, and a question mark ? if their relation is unknown.

It is guaranteed that there exists at least one configuration consistent with this matrix.

Output Format

Output a single line containing three integers: c1,c2,c3c_1,c_2,c_3.

6 2 5
?+????
-?+???
?-????
????+?
???-?+
????-?
1 4 1
14 8 4
?+???++?????++
-??=?=???????=
??????????=???
?=??+?==??????
???-???-???-??
-=????????????
-??=???=?-+???
???=+?=???????
??????????????
??????+???????
??=???-????-??
????+?????+???
-?????????????
-=????????????
18 12 11

Hint

Constraints: 4n504\le n\le 50.

Translated by ChatGPT 5