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

34507번 - Scary Subsequences 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB219842.105%

문제

In this problem, all strings consist only of four characters: a, b, c, and d.

Busy Beaver has three strings $x,ドル $y,ドル and $z$ that he's really scared of. In particular, he only likes strings that are not a subsequence of any of them.

Answer $Q$ queries. In query $i,ドル you are given a string $s_i,ドル such that $x,ドル $y,ドル and $z$ are all subsequences of $s_i$ and $|s_i| > \max(|x|, |y|, |z|)$. Help Busy Beaver find the length of the shortest subsequence of $s_i$ that is not a subsequence of any of $x,ドル $y,ドル or $z$.


1A string $s$ is a subsequence of a string $t$ if $s$ can be obtained from $t$ by deleting some (possibly none or all) characters from $t,ドル without reordering the remaining characters.

입력

The first three lines of the input contain the strings $x,ドル $y,ドル and $z$ (1ドル \le |x|, |y|, |z| \le 60$), consisting of characters a, b, c, d.

The next line contains a single positive integer $Q$ (1ドル \le Q \le 1.5 \cdot 10^5$).

The next $Q$ lines each contain a string, the $i$-th of which is $s_i$ ($\max(|x|, |y|, |z|) < |s_i| \leq 3 \cdot 10^5$), consisting of characters a, b, c, d such that $s_i$ has $x,ドル $y,ドル and $z$ as subsequences.

The sum of $|s_i|$ over all queries does not exceed 3ドル \cdot 10^5$.

출력

On the $i$-th line, output a single positive integer --- the shortest possible length of a subsequence of $s_i$ that is not a subsequence of any of $x,ドル $y,ドル or $z$.

제한

예제 입력 1

abb
bcc
abcc
3
abcbc
dabcabc
abbcc

예제 출력 1

2
1
3

노트

In the first query, all length 1ドル$ subsequences of abcbc are subsequences of one of $x,ドル $y,ドル or $z,ドル but the subsequence cb is not, so the answer is 2ドル$.

In the second query, d is a subsequence of dabcabc that is not a subsequence of any of $x,ドル $y,ドル or $z$.

In the third query, bbc is a subsequence of abbcc that is not a subsequence of any of $x,ドル $y,ドル or $z,ドル and it is the shortest such subsequence.

출처

University > MIT > M(IT)^2 > M(IT)^2 Spring 2025 Invitational > Finals 4번

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

출처

대학교 대회

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

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