아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Abbreviated Aliases

면접 대비

시간 제한2초메모리 제한2048 MB

요약
길이가 같은 서로 다른 문자열 n개가 주어질 때, 다른 문자열과 겹치지 않는 가장 짧은 접두사만 저장하고 그 총길이를 구한다.
난이도

보통10점 중 4점

유형
트라이, 문자열, 정렬, 그리디
정답자
아직 제출이 없습니다

문제

You are the owner of a large successful internet site with lots of users. All these users have chosen an alias of exactly ll characters for logging into the site. Recently, you noticed that you started running into disk space issues: storing all these aliases takes up a lot of data!

You do not have enough money to buy extra storage, so you are looking for ways to reduce the storage space needed. A friend gives you the following compression idea that might help: instead of storing the full alias for each user, you might get away with only storing a prefix of that alias, as long as no other alias has the same prefix. For example, if you just have the aliases james and jacob, you can store only jam and jac and still be able to identify them both.

This idea sounds quite interesting to you, and you are looking forward to finally having more space available on your disk again. You would like to find out how much space you need to store all aliases using this compression technique.

입력

The input consists of:

  • One line with two integers nn and ll (2≤n≤1042 \le n \le 10^4, 1≤l≤1031 \le l \le 10^3), the number of aliases and the length of each alias.
  • nn lines, each with an alias: a string consisting of exactly ll English lowercase characters (a-z). Each alias is unique.

출력

Output the total number of characters you still need to store if you apply this compression technique.

예제2

  1. 예제 1

    입력
    2 5
    james
    jacob
    
    예상 출력
    6
    
  2. 예제 2

    입력
    4 4
    xxxx
    yxxx
    xxyx
    yxxy
    
    예상 출력
    14