CF251B Playing with Permutations
题目背景
简易形式化翻译
给定一个排列 $q$,初始你有一个排列 $p$ 为 $1,2,3,\cdots,n$。
你可以进行两种操作:
1. $\forall i\in[1,n],p_i\gets p_{q_i}$,注意所有赋值操作是同时进行的。
2. $\forall i\in[1,n],p_{q_i}\gets p_i$,注意所有赋值操作是同时进行的。
你需要输出是否存在一种方案,在进行**恰好** $k$ 次操作后使 $p$ 变为排列 $s$ 且在此之前从未得到过排列 $s$。
题目描述
Little Petya likes permutations a lot. Recently his mom has presented him permutation $ q_{1},q_{2},...,q_{n} $ of length $ n $ .
A permutation $ a $ of length $ n $ is a sequence of integers $ a_{1},a_{2},...,a_{n} $ $ (1
输入格式
The first line contains two integers $ n $ and $ k $ ( $ 1
输出格式
If the situation that is described in the statement is possible, print "YES" (without the quotes), otherwise print "NO" (without the quotes).
说明/提示
In the first sample Masha's permutation coincides with the permutation that was written on the board before the beginning of the game. Consequently, that violates the condition that Masha's permutation never occurred on the board before $ k $ moves were performed.
In the second sample the described situation is possible, in case if after we toss a coin, we get tails.
In the third sample the possible coin tossing sequence is: heads-tails-tails.
In the fourth sample the possible coin tossing sequence is: heads-heads.