Logo
(追記) (追記ここまで)

31146번 - ABC Legacy 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB51272553.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$).

제한

예제 입력 1

3
BABBCC

예제 출력 1

YES
3 5
1 6
2 4

예제 입력 2

2
CBAC

예제 출력 2

NO

예제 입력 3

1
AA

예제 출력 3

NO

예제 입력 4

3
ABCACB

예제 출력 4

YES
2 3
4 6
1 5

힌트

출처

Contest > Open Cup > 2021/2022 Season > Stage 7: Grand Prix of Southeastern Europe A번

ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2021 J번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /