P29501 [洛谷] [NEERC2017] Easy Quest
普及+
题目描述

Problem Description

A young hero is embarking on his heroic journey. The wise wizard advises him to start with an easy quest. During this quest, the young hero encounters \( n \) magical creatures in a specific order. To assist the young hero, the wizard provides him with a list of \( n \) integers \( a_i \).

If \( a_i \) is positive, the \( i \)-th magical creature is benevolent and gives the hero one magical item of type \( a_i \). The hero can possess multiple items of the same type.

If \( a_i \) is negative, the \( i \)-th magical creature is malevolent, and to defeat it, the hero needs one magical item of type \( -a_i \). All magical items are single-use and fragile.

If \( a_i \) is zero, the \( i \)-th creature is a unicorn. It provides the hero with any magical item he requests, but only one.

Your task is to determine if the young hero can complete the quest by defeating all enemies along the way. If possible, specify the types of items the hero should request from the unicorns in the order they are encountered.

Input Format

The first line of input contains one integer \( n \) (\( 1 \le n \le 1000 \)). The second line contains \( n \) integers \( a_i \) (\( -1000 \le a_i \le 1000 \)).

Output Format

If it is impossible to defeat all enemies, output the string No. If it is possible, output the string Yes, followed by a line specifying the types of items the hero should request from the unicorns, in the order they are encountered. The types must be integers between 1 and 1000 inclusive. If there are multiple solutions, output any one of them.

Sample Input and Output

Sample Input #1

10
1 0 -4 0 0 -1 -3 0 -1 -2

Sample Output #1

Yes
4 1 3 2

Sample Input #2

5
5 8 0 -6 -3

Sample Output #2

No

Sample Input #3

3
2 -2 -2

Sample Output #3

No

Notes

Time limit: 3 seconds, Memory limit: 512 MB.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
10 1 0 -4 0 0 -1 -3 0 -1 -2
样例输出
Yes 4 1 3 2