아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Colorful Doors

시간 제한2초메모리 제한256 MB

요약
길이 2N-1인 통과 구간 기록이 주어질 때, 각 색의 문이 정확히 두 개인 배치 중 기록과 맞는 것을 찾아 출력한다.
난이도

보통10점 중 7점

유형
스택, 그리디, 구현
정답자
아직 제출이 없습니다

문제

There is a bridge that connects left and right banks of a river. There are 2N2 N doors placed at different positions on this bridge, painted in some colors. The colors of the doors are represented by integers from 11 through NN. For each kk (1≤k≤N1 \leq k \leq N), there are exactly two doors painted in color kk.

Snuke decides to cross the bridge from the left bank to the right bank. He will keep on walking to the right, but the following event will happen while doing so: At the moment Snuke touches a door painted in Color kk (1≤k≤N1 \leq k \leq N), he teleports to the right side of the other door painted in color kk.

It can be shown that he will eventually get to the right bank.

For each ii (1≤i≤2N−11 \leq i \leq 2 N - 1), the section between the ii-th and (i+1)(i + 1)-th doors from the left will be referred to as section ii. After crossing the bridge, Snuke recorded whether or not he walked through Section ii, for each ii (1≤i≤2N−11 \leq i \leq 2 N - 1). This record is given to you as a string ss of length 2N−12 N - 1. For each ii (1≤i≤2N−11 \leq i \leq 2 N - 1), if Snuke walked through section ii, the ii-th character in ss is '1'; otherwise, the ii-th character is '0'.

Determine if there exists an arrangement of doors that is consistent with the record. If it exists, construct one such arrangement.

입력

Input is given in the following format:

 NN 

 ss

출력

If there is no arrangement of doors that is consistent with the record, print "No". If there exists such an arrangement, print "Yes" in the first line, then print one such arrangement in the second line, in the following format: c_1c\_1 c_2c\_2 ...... c_2Nc\_{2 N}. Here, for each ii (1≤i≤2N1 \leq i \leq 2 N), c_ic\_i is the color of the ii-th door from the left.

제한

NN is integer, (1≤N≤1051 \leq N \leq 10^5), ss consists of '0' and '1', ∣s∣=2N−1|s| = 2 N - 1.

예제5

  1. 예제 1

    입력
    2
    010
    
    예상 출력
    Yes
    1 1 2 2
    
  2. 예제 2

    입력
    2
    001
    
    예상 출력
    No
    
  3. 예제 3

    입력
    3
    10110
    
    예상 출력
    Yes
    1 3 2 1 2 3
    
  4. 예제 4

    입력
    3
    10101
    
    예상 출력
    No
    
  5. 예제 5

    입력
    6
    00111011100
    
    예상 출력
    Yes
    1 6 1 2 3 4 4 2 3 5 6 5