#P1752. Train Wreck

Train Wreck

题目描述

You are now the coordinator for the Nonexistent Old Railway Station! The Nonexistent Old Railway Station only has one track with a dead end, which acts as a stack: everytime you either push a train into the station, or pop the most recently added train out of the station.

Everyday, n trains gets push into and pop out of the station. The inspector has already decided today's sequence of pushing'' and popping''. You now have a list of the colored trains and have to assign each train to one ``pushing'' in inspector's sequence.

Meanwhile, the inspector also requires you to make the sequence of trains remaining on the track unique every time you push a train onto it. Two sequence of trains are considered different if the length is different or the i-th train in the two sequences have a different color.

Output a solution or decide that it is impossible.

输入格式

输出格式

If there is no solution, output ``NO'' in one line.

Otherwise, output ``YES'' in the first line, and n intergers in the second line, indicating the color of the i-th train that is being pushed.

样例

3 
()()() 
1 2 2
NO
4 
()(())() 
1 2 4 4
YES 
4 2 4 1

提示

In the first sample case, all 3 train color sequences are always going to be [1],[2] and [2] (not necessarily in that order), thus it is impossible to satisfy the inspector.

In the second sample case, the 4 train color sequences in the sample output are [4], [2], [2, 4] and [1] (in that order), we can see that all these are unique.

by 艾拉拉