

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 500 点
問題文
正整数列 A=(a_1,\ldots,a_N) が与えられます。
次の操作を 0 回以上 10^4 回以下繰り返すことで A の値をすべて等しくできるかを判定し、可能な場合は操作列の一例を示してください。
- (1,\ldots,N) の順列 (p_1,\ldots,p_N) を決め、A を (a_1+p_1,\ldots,a_N+p_N) に置き換える。
制約
- 2 \leq N \leq 50
- 1 \leq a_i \leq 50
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N a_1 \ldots a_N
出力
A の値をすべて等しくできない場合は No
と出力せよ。
等しくできる場合、操作回数を M 回、i 回目の操作における順列を (p_{i,1},\ldots,p_{i,N}) として以下の形式で出力せよ。
Yes M p_{1,1} \ldots p_{1,N} \vdots p_{M,1} \ldots p_{M,N}
答えが複数存在する場合はどれを出力しても正解とみなされる。
入力例 1
2 15 9
出力例 1
Yes 8 1 2 1 2 1 2 1 2 2 1 1 2 1 2 1 2
この出力例の通りに 8 回の操作を行うことで A は (24,24) となり、値がすべて等しくなります。
入力例 2
5 1 2 3 10 10
出力例 2
No
入力例 3
4 1 1 1 1
出力例 3
Yes 0
初めから A の値がすべて等しいです。
Score : 500 points
Problem Statement
You are given a sequence of positive integers: A=(a_1,\ldots,a_N).
Determine whether it is possible to make all elements of A equal by repeating the following operation between 0 and 10^4 times, inclusive. If it is possible, show one way to do so.
- Choose a permutation (p_1,\ldots,p_N) of (1,\ldots,N), and replace A with (a_1+p_1,\ldots,a_N+p_N).
Constraints
- 2 \leq N \leq 50
- 1 \leq a_i \leq 50
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
N a_1 \ldots a_N
Output
If it is impossible to make all elements of A equal, print No
.
If it is possible, print one way to do so in the following format, where M is the number of operations, and (p_{i,1},\ldots,p_{i,N}) is the permutation chosen in the i-th operation:
Yes M p_{1,1} \ldots p_{1,N} \vdots p_{M,1} \ldots p_{M,N}
If multiple solutions exist, you may print any of them.
Sample Input 1
2 15 9
Sample Output 1
Yes 8 1 2 1 2 1 2 1 2 2 1 1 2 1 2 1 2
This sequence of 8 operations makes A = (24,24), where all elements are equal.
Sample Input 2
5 1 2 3 10 10
Sample Output 2
No
Sample Input 3
4 1 1 1 1
Sample Output 3
Yes 0
All elements of A are equal from the beginning.