問題一覧 > 通常問題

No.2107 Entangled LIS

レベル : / AI推定難易度 : 2525 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 10
作問者 : Sumitacchan / テスター : 👑 hitonanode ygussany
お気に入りにしたユーザー ProblemId : 8330 / 自分の提出
問題文最終更新日: 2022-10-08 11:14:03
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 365 (順位表) の他の問題:

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=$ a then $a_i > b_i$, and if $s_i=$ b then $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 Yes and $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もしくは右上の雲マークをクリックしてアカウントを作成してください。