2020 C Chapter 11 - 문자열과 문자열 함수

From: 2020-03-16 00:00:00 To: 2020-07-01 00:00:00 Now: 2024-05-09 09:25:43 Status: Public

G - 아버지가방에들어가신다 (Challenge)

Time Limit: 1s Memory Limit: 128MB

Submissions: 9 Solved: 2
Description

사전에 있는 단어들을 사용하여 주어진 문장을 만들 때, 최소 몇 개의 단어를 사용해서 만들 수 있을지 구해보자.

단, 사전의 단어에 대소문자 구별은 없으며, 사전의 단어가 여러 번 들어갈 수 있다.

Input

Line 1:띄어쓰기 없는 문장 (최대 500자)

Line 2: 단어 갯수 N (1≤N≤120)

Line 3~N+2: 단어 (최대 30자)

Output

Line 1: 필요한 단어갯수의 최솟값

Sample Input
ItsabeautifuldayoutsideBirdsaresingingflowersareblooming
49
g
it
blooming
u
its
e
re
de
gin
side
outside
b
sin
birds
er
f
are
we
a
day
w
in
be
r
i
l
lower
out
singing
ay
flowers
beautiful
y
n
flower
mi
ti
si
bloom
flow
low
t
d
if
lo
owe
m
o
sing
Sample Output
11