#C11289. Secret Santa Arrangement
Secret Santa Arrangement
Secret Santa Arrangement
You are given an integer N and a sequence of N integers representing the Secret Santa assignment for each friend. In this arrangement, every friend gives exactly one gift and every friend receives exactly one gift. In other words, the sequence must be a permutation of the set \(\{1, 2, \dots, N\}\).
The task is to determine whether the given assignment is valid. An assignment is valid if and only if:
- The sequence contains exactly N integers.
- Every integer is in the range \(1 \leq a_i \leq N\).
- Each integer from 1 to \(N\) appears exactly once.
Read the input from standard input (stdin
) and print the result to standard output (stdout
). Output "Yes" if the arrangement is valid and "No" otherwise.
inputFormat
The input is given in two lines:
- The first line contains a single integer \(N\), representing the number of friends.
- The second line contains \(N\) space-separated integers, where the \(i\)-th integer is the friend ID that receives a gift from the \(i\)-th friend.
outputFormat
Print a single line containing either "Yes" if the assignment is a valid Secret Santa arrangement or "No" if it is not.
## sample4
2 3 4 1
Yes