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

21976번 - Crossing 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB42222052.632%

문제

Do you know Just Odd Investigations Laboratory? The business of this laboratory is to do “just odd investigations.” In the following, we call it JOI Laboratory for short.

In recent years, broad gardens with splendid flowers were discovered in several historical ruins in the world. JOI Laboratory discovered that the flowers in these gardens are new species, and their genes have similar features. The genes of these new flowers are strings of length N consisting of J, O, I. These strings are called gene sequences.

You are a researcher working in JOI Laboratory. You initially have three flowers of new species. Their gene sequences are SA, SB, SC, respectively.

You can obtain a flower of new species from two flowers of new species by an operation called crossing. The i-th character (1 ≤ i ≤ N) of the gene sequence of the new flower is determined by the following rule.

  • If the i-th characters of the gene sequences of the two flowers are the same, the i-th character of the gene sequence of the new flower will be the same character.
  • If the i-th characters of the gene sequences of the two flowers are different, the i-th character of the gene sequence of the new flower will be one of J, O, or I which is different from these two characters.

In other words, if the i-th characters of the gene sequences of the two flowers are c1 and c2, the i-th character c3 of the gene sequence of the new flower is given by the following table.

c1 J J J O O O I I I
c2 J O I J O I J O I
c3 J I O I O J O J I

You may use the same flower for crossing as many times as you want. If you obtain a new flower by crossing, you may use it for subsequent crossings.

In order to obtain more beautiful flowers, JOI Laboratory proposed (Q + 1) gene sequences numbered from 0 to Q as candidate gene sequences. You are given a list describing the candidate gene sequences. The list contains a string T0 and, for each j (1 ≤ j ≤ Q), integers Lj, Rj and a character Cj. The candidate gene sequences are given as follows.

  • The candidate gene sequence 0 is T0.
  • The candidate gene sequence j (1 ≤ j ≤ Q) is obtained from the candidate gene sequence j − 1 by replacing the characters from the Lj-th position to the Rj-th position by the character Cj.

Write a program which, given an integer N, the gene sequences of the three initial flowers, and the list describing the candidate gene sequences, determines, for each candidate gene sequence, whether it is possible to obtain a flower whose gene sequence is the given one from the three initial flowers by crossing zero or more times.

입력

Read the following data from the standard input.

N
SA
SB
SC
Q
T0
L1 R1 C1
.
.
.
LQ RQ CQ

출력

Write (Q + 1) lines to the standard output. In the (j + 1)-th line (0 ≤ j ≤ Q), output Yes if it is possible to obtain a flower whose gene sequence is the candidate gene sequence j from the three initial flowers by crossing zero or more times. Otherwise, output No.

제한

  • 1 ≤ N ≤ 200 000.
  • SA, SB, SC are strings of length N. Each character is either J, O, or I.
  • 1 ≤ Q ≤ 200 000.
  • T0 is a string of length N. Each character is either J, O, or I.
  • 1 ≤ Lj ≤ Rj ≤ N (1 ≤ j ≤ Q).
  • Cj is either J, O, or I (1 ≤ j ≤ Q).

서브태스크

번호배점제한
13

SA = SB = SC, N ≤ 100.

223

SA = SB = SC.

323

N ≤ 100.

451

No additional constraints.

예제 입력 1

4
JOJO
JJOI
OJOO
3
IJOJ
1 4 O
2 2 J
2 4 I

예제 출력 1

Yes
No
Yes
Yes

The gene sequences of the three initial flowers are JOJO, JJOI, and OJOO. In the following, new flowers obtained by crossing are written as their gene sequences.

  1. T0 is IJOJ. Since it is possible to obtain IJOJ by crossing JJOI with OJOO, output Yes.
  2. T1 is OOOO. Since it is impossible to obtain OOOO from the three initial flowers by crossing zero or more times, output No.
  3. T2 is OJOO. Since you have OJOO in the beginning without crossing, output Yes.
  4. T3 is OIII. You can obtain IJOJ by crossing JJOI with OJOO. Then you can obtain OIII by crossing JOJO with IJOJ. Therefore, output Yes.

This sample input satisfies the constraints of Subtasks 3, 4.

예제 입력 2

3
JOI
JOI
JOI
2
OJI
1 2 O
1 1 J

예제 출력 2

No
No
Yes

The gene sequences of the three initial flowers are JOI only. You can obtain JOI only by crossing.

  1. T0 is OJI. Since it is impossible to obtain this flower by crossing, output No.
  2. T1 is OOI. Since it is impossible to obtain this flower by crossing, output No.
  3. T2 is JOI. Since it is possible obtain this flower, output Yes.

This sample input satisfies the constraints of Subtasks 1, 2, 3, 4.

힌트

출처

Contest > JOI Open Contest > JOI Open Contest 2021 1번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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