#P10442. 「MYOI-R3」字符串

    ID: 11694 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>模拟字符串洛谷原创O2优化洛谷月赛

「MYOI-R3」字符串

Problem Description

Given strings s,ts, t.

Now you need to delete some characters in s,ts, t and reorder the remaining characters so that s=ts = t.

What is the maximum possible value of s|s| (i.e., the length of string ss) after the operations?

Input Format

The first line contains a string ss.

The second line contains a string tt.

Output Format

Output one integer in one line, representing the maximum possible value of s|s| after the operations.

abc
bc
2
aaaaa
bbbbb
0

Hint

In the first sample, delete a and keep bc.

Then s=2|s| = 2, and it can be proven that this is optimal.

In the second sample, delete aaaaa and keep the empty string.
Delete bbbbb and keep the empty string.

Then s=0|s| = 0, and it can be proven that this is optimal.

This problem uses bundled testdata.

Let n=max(s,t)n = \max(|s|, |t|).

Subtask\text{Subtask} nn \le Special Property Total Score
11 1010 None 2525
22 10510^5 A\text{A}
33 B\text{B}
44 None

Constraints: For 100%100\% of the data, 1s,t1051 \le |s|, |t| \le 10^5. Both strings consist of lowercase letters.

Special Property A\text{A}: ss is a permutation of az\text{a} \sim \text{z}.

Special Property B\text{B}: It is guaranteed that si,ti{a,b}s_i, t_i \in \{\text{a}, \text{b}\}.

Translated by ChatGPT 5