SnowflakeOA #34
String Search (Also for Core/Database Engineering)
估计中等可在线判题
Delete characters of source one by one following order, a permutation of 1-based original indices; original indices are not renumbered after deletions. target is initially guaranteed to be a subsequence of source. Find the maximum number of leading deletions that can be performed consecutively while target remains a subsequence.
输入格式
The first two lines contain source and target (words without whitespace characters), and the last line contains a 1-based permutation of indices whose length equals the length of source. 1≤|source|≤100000, 1≤|target|≤|source|. Letter case is not arbitrarily restricted, and comparisons are case-sensitive.
输出格式
Output the single integer required by the problem.
样例 1
输入:
abbabaa
bb
7 1 2 5 4 3 6
输出:
3
样例 2
输入:
hkbdi
kd
1 4 2 3 5
输出:
1
样例 3
输入:
AaA
A
1 3 2
输出:
1
样例说明
The answers to the three public examples are, in order: 3; 1; 1. The examples were rechecked by independent enumeration, state search, or direct simulation.