当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。
i (tester) | j (testee)/td> | test outcome ai,j |
truth-teller | truth-teller | 0 |
truth-teller | liar | 1 |
liar | truth-teller | 0 or 1 |
liar | liar | 0 or 1 |
Testing is performed circularly as follows: person 1 tests person 2, person 2 tests person 3,..., person n-1 tests
person n, and person n tests person 1. From the test outcomes, some persons are definitely liars, but some
others may or may not be liars. From n, t, and the test outcomes, determine the persons who are definitely liars.
For example, let n = 5, t = 2, and the test outcomes (a1,2, a2,3, a3,4, a4,5, a5,1) be (0, 1, 1, 0, 0). In the following
figure, each circle represents a person, and the label on the edge (i, j) represents the test outcome ai,j.
In this example, person 3 should be a liar because if not, person 4 is liar and persons 2 is liar, thus persons 1, 5,
and 4 become liars, which contradicts the condition that the number of liars does not exceed t = 2. Therefore
person 3 is determined as a definite liar. However, because both {person 3, person 4} and {person 3} can be
sets of liars, we can't determine that person 4 is a liar.
Given n (the number of persons), t (the maximum number of liars), and the set of test outcomes, write a
program to find all the persons who are definitely liars. It is assumed that the given set of outcomes is one that
results from some liars who are less than or equal to t.
3 5 2 0 1 1 0 0 7 2 0 0 1 0 0 1 1 9 8 1 0 0 0 0 1 0 0 0
1 3 2 4 0 0
时间上限 | 内存上限 |
1000 | 10000 |