#P1026. [NOIP 2001 提高组] 统计单词个数

    ID: 26 远端评测题 1000ms 128MiB 尝试: 1 已通过: 1 难度: 6 上传者: 标签>字符串动态规划,dp2001NOIp 提高组枚举,暴力

[NOIP 2001 提高组] 统计单词个数

Description

You are given a string of lowercase English letters with length at most 200200 (the string is provided as 2020 letters per line, and each line has exactly 2020 letters). You must split this string into kk contiguous parts so that the total number of words contained in all parts is maximized.

Words in a part may partially overlap. After selecting one word, its first letter cannot be used again. For example, the string this can contain both this and is, but if this is selected, then th cannot be included.

The set of words comes from a given dictionary of at most 66 words.

Output the maximum count.

Input Format

The input consists of multiple test cases. For each test case:

  • The first line contains two positive integers p,kp, k. Here pp is the number of lines of the string, and kk is the number of parts to split into.
  • The next pp lines each contain exactly 2020 characters.
  • The next line contains a positive integer ss, the number of dictionary words.
  • The next ss lines each contain one word.

Output Format

For each test case, output one integer: the corresponding result.

1 3
thisisabookyouareaoh
4
is
a
ok
sab

7

Hint

  • Constraints: For 100%100\% of the testdata, 2k402 \le k \le 40, 1s61 \le s \le 6.
  • Sample explanation: A valid partition is this / isabookyoua / reaoh.
  • Source: NOIP 2001 Senior, Problem 3.

Translated by ChatGPT 5