#K78507. Token Passing Analysis
Token Passing Analysis
Token Passing Analysis
This problem involves a token passing game among friends. There are \( n \) friends numbered from 1 to \( n \). Each friend \( i \) passes a token to friend \( f_i \). Your task is to determine whether there is at least one friend who never receives the token. Formally, given the sequence \( f_1, f_2, \ldots, f_n \), check if there exists a friend \( j \) such that no \( i \) satisfies \( f_i = j \).
inputFormat
The input consists of two lines:
- The first line contains an integer \( n \) (the number of friends).
- The second line contains \( n \) space-separated integers \( f_1, f_2, \ldots, f_n \), where the \( i^{th} \) integer represents the friend who receives the token from friend \( i \).
outputFormat
Output a single line containing YES
if there exists at least one friend who never receives the token; otherwise, output NO
.
5
2 3 4 5 1
NO