Train Wreck
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
Special Judge, 64bit IO Format: %lld

题目描述

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.

输入描述:

The first line contains one integer (), indicating the number of trains.

The second line contains a bracket sequence of length , with each ``('' indicating one ``pushing'' and ``)''indicating one ``popping''. The input guarantees that the sequence is always valid and balanced.

The third line contains n numbers k_i (), indicating the color of the -th train.

输出描述:

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

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

输入

复制
3
()()()
1 2 2

输出

复制
NO
示例2

输入

复制
4
()(())()
1 2 4 4

输出

复制
YES
4 2 4 1

备注:

In the first sample case, all  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 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.