#K68267. Event Scheduling
Event Scheduling
Event Scheduling
You are given an integer \(n\) representing the number of events and a list of \(n\) integers. Each integer represents the specific day on which an event must be held, where 0 indicates that there is no pre-assigned day. The available days are labeled from 1 to \(n\). Your goal is to determine whether it is possible to assign each event a day such that:
- Events with a fixed day (non-zero value) must be scheduled exactly on that day, and no two events can be scheduled on the same day.
- Events without a fixed day (denoted by 0) can be scheduled on any of the remaining available days.
If a valid scheduling exists, output YES followed by one possible valid order of event days. Otherwise, output NO.
inputFormat
The input is given via standard input and consists of two lines:
- The first line contains a single integer \(n\) (\(1 \le n \le 10^5\)), the number of events.
- The second line contains \(n\) space-separated integers. Each integer is either 0 or an integer from 1 to \(n\). A value of 0 indicates that the event does not have a fixed day, while a non-zero value indicates a fixed day.
outputFormat
If a valid schedule exists, print YES on the first line, and on the second line print \(n\) space-separated integers representing a valid assignment of days to events. If no valid schedule exists, print NO.
## sample3
1 0 2
YES
1 3 2
</p>