| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 51 | 27 | 25 | 53.191% |
You are given a string $S$ of length 2ドルn,ドル consisting of the characters A, B and C. Determine if $S$ can be split into $n$ non-intersecting subsequences, each of which forms one of the strings "AB", "AC", "BC". If it is possible, find such a splitting.
The first line of input contains one integer $n$ (1ドル \le n \le 10^5$).
The second line of input contains a string $S$ of length 2ドルn,ドル consisting of the characters A, B and C.
If the splitting is not possible, print "NO" (without quotes).
If the splitting is possible, print "YES" (without quotes), followed by $n$ lines, each describing two indices for the $i$-th subsequence (1ドル \le l_i < r_i \le 2n$).
3 BABBCC
YES 3 5 1 6 2 4
2 CBAC
NO
1 AA
NO
3 ABCACB
YES 2 3 4 6 1 5