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

建议使用的浏览器:

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

5165:Funny Game

题目描述
Bob has an array \(\{a_1,a_2,\dots,a_n\}\), each element is an integer between 1 and \(n\). Bob also has \(m\) functions whose domain and codomain are both \(\{1, 2, \dots, n\}\). Bob and Alice begin to play a game on the array. Alice plays first. For each turn, the player can choose a function \(f\) and make every \(a_i\ (1 \le i \le n)\) become \(f(a_i)\). For example, the array is \(\{1, 1, 2, 4, 5\}\) and \(f(1) = 1, f(2) = 3, f(3) = 4, f(4) = 1, f(5) = 2\). Then after the operation the array will become \(\{1, 1, 3, 1, 2\}\). If all the element in the array is same, then Alice wins and the game stops. So you can see that Bob's goal is to stop Alice. Suppose that both Alice and Bob play optimally. Alice wants to know if she can always win no matter what the array looks like.
输入解释
There are multiple test cases. The first line of input contains an integer \(T\ (1 \le T \le 200)\), indicating the number of test cases. For each test case: The first line contains two integers \(n\) and \(m\) (\(1 \le n, m \le 100\)), indicating the element in the array and the number of functions. In the next \(m\) lines, each contains \(n\) integers \(f(1), f(2), \dots, f(n)\) (\(1 \le f(i) \le n, 1 \le i \le n\)).
输出解释
For each case, output "YES"(without quotes) if Alice can always win no matter what the array looks like, otherwise output "NO"(without quotes).
输入样例
2
5 1
1 3 4 1 2
5 1
2 3 4 5 1
输出样例
YES
NO
来自杭电HDUOJ的附加信息
Recommend hujie

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

题目来源 BestCoder Round #27

源链接: HDU-5165

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

共提交 0

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