Codeforces Round 358 (Div. 2)
D
Alyona and Strings
Codeforces
1900
原题
← CE →
翻译中…

After returned from forest, Alyona started reading a book. She noticed strings $*s*$ and $*t*$, lengths of which are $*n*$ and $*m*$ respectively. As usual, reading bored Alyona and she decided to pay her attention to strings $*s*$ and $*t*$, which she considered very similar.

翻译中…

Alyona has her favourite positive integer $*k*$ and because she is too small, $*k*$ does not exceed $10$. The girl wants now to choose $*k*$ disjoint non-empty substrings of string $*s*$ such that these strings appear as disjoint substrings of string $*t*$ and in the same order as they do in string $*s*$. She is also interested in that their length is maximum possible among all variants.

翻译中…

Formally, Alyona wants to find a sequence of $*k*$ non-empty strings $*p*_{1}, *p*_{2}, *p*_{3}, ..., *p*_{*k*}$ satisfying following conditions:

翻译中…
  • $*s*$ can be represented as concatenation $*a*_{1}*p*_{1}*a*_{2}*p*_{2}... *a*_{*k*}*p*_{*k*}*a*_{*k* + 1}$, where $*a*_{1}, *a*_{2}, ..., *a*_{*k* + 1}$ is a sequence of arbitrary strings (some of them may be possibly empty);
  • $*t*$ can be represented as concatenation $*b*_{1}*p*_{1}*b*_{2}*p*_{2}... *b*_{*k*}*p*_{*k*}*b*_{*k* + 1}$, where $*b*_{1}, *b*_{2}, ..., *b*_{*k* + 1}$ is a sequence of arbitrary strings (some of them may be possibly empty);
  • sum of the lengths of strings in sequence is maximum possible.
翻译中…

Please help Alyona solve this complicated problem and find at least the sum of the lengths of the strings in a desired sequence.

翻译中…

A substring of a string is a subsequence of consecutive characters of the string.

翻译中…

Input

翻译中…

In the first line of the input three integers $*n*$, $*m*$, $*k*$ ($1 ≤ *n*, *m* ≤ 1000$, $1 ≤ *k* ≤ 10$) are given — the length of the string $*s*$, the length of the string $*t*$ and Alyona's favourite number respectively.

翻译中…

The second line of the input contains string $*s*$, consisting of lowercase English letters.

翻译中…

The third line of the input contains string $*t*$, consisting of lowercase English letters.

翻译中…

Output

翻译中…

In the only line print the only non-negative integer — the sum of the lengths of the strings in a desired sequence.

翻译中…

It is guaranteed, that at least one desired sequence exists.

翻译中…

Note

翻译中…

The following image describes the answer for the second sample case:

翻译中…

image

翻译中…

样例

Input #1
3 2 2
abc
ab
Output #1
2
InputCopy OutputCopy
Input #2
9 12 4
bbaaababb
abbbabbaaaba
Output #2
7
InputCopy OutputCopy
题目信息
题号
682D
时间限制
2 s
内存限制
256 MB
标签
动态规划
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。