No.2107 Entangled LIS
タグ : / 解いたユーザー数 10
作問者 :
Sumitacchan
/ テスター :
👑
hitonanode
Problem Statement
You are given a string $s=s_1s_2\dots s_N$ of length $N$ consisting of a,b, and positive integers $A,B$.
Does there exist a pair of integer sequences of length $N$, $a=(a_1,a_2,\dots,a_N),b=(b_1,b_2,\dots,b_N)$, satisfying all of the following conditions?
- Among the $2N$ integers $a_1,a_2,\dots,a_N,b_1,b_2,\dots,b_N$, each integer between $1$ and $2N$, inclusive, appears exactly $1$ time.
- The length of the longest increasing subsequence of the integer sequence $a=(a_1,a_2,\dots,a_N)$ is $A$.
- The length of the longest increasing subsequence of the integer sequence $b=(b_1,b_2,\dots,b_N)$ is $B$.
- For each $i=1,2,\dots,N$, if $s_i=$
athen $a_i > b_i$, and if $s_i=$bthen $a_i < b_i$.
If such a pair exists, show one such pair of integer sequences $a,b$.
For each input, answer $T$ test cases.
Constraints
- $1 \le T \le 2 \times 10^4$
- $1 \le N \le 2 \times 10^5$
- $1 \le A,B \le N$
- $T,N,A,B$ are integers.
- $s$ is a string of length $N$ consisting of
a,b. - The sum of $N$ over the $T$ test cases in a single input is at most $2\times10^5$.
Input
First, line $1$ contains the number of test cases $T$ in the input.
$T$
Then, $T$ test cases follow over $2T$ lines. Each test case is given over $2$ lines in the following format.
$N\ \ A\ \ B$ $s$
Output
Output the answers to the test cases in order as follows, with a line break after each test case.
- If no pair of integer sequences $a,b$ satisfying the conditions exists, output
No. - If one exists, output
Yesand $a,b$ in the following format (if multiple pairs $a,b$ satisfy the conditions, you may output any of them).Yes $a_1\ \ a_2\ \ \cdots\ \ a_N$ $b_1\ \ b_2\ \ \cdots\ \ b_N$
Sample
Sample 1
Input
3 4 3 2 bbaa 2 2 1 ab 5 5 5 bbbbb
Output
Yes 1 7 5 6 3 8 4 2 No Yes 1 2 3 4 5 6 7 8 9 10
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。