QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100

#4666. 删除与获得

統計

给定两个由小写英文字母组成的字符串。

其中一个是样本字符串,你不能对其进行修改。你的任务是通过删除另一个字符串中的某些字符,使其在字典序上小于样本字符串。请找出为了达到这一目标所需删除的最少字符数。

如果字符串 $s$ 是字符串 $t$ 的前缀(且 $s \neq t$),或者在 $s$ 和 $t$ 第一个不同的位置上,$s$ 的字符在字母表中比 $t$ 的字符小,则称字符串 $s$ 在字典序上小于字符串 $t$。

输入格式

输入包含两行,每行一个由小写英文字母组成的字符串。第一行是你可以修改的字符串,第二行是样本字符串。两个字符串的长度均至少为 $1$,至多为 $10^5$。

输出格式

输出一行,包含一个整数,即问题的答案。

样例

样例输入 1

pqsrpspqz
pqrpqz

样例输出 1

2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.