#675
Unrated
Identity Theft
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Note: The time limit and memory limit for this problem are 3s and 512MB, which are 1.5x and 2x the normal amount, respectively.

Farmer John's NN (1N1051 \leq N \leq 10^5) cows each have a Farm ID number in the form of a bitstring (a string consisting of the characters '0' and '1'). Bessie, the eldest cow, has the Farm ID numbers of all the cows memorized, and likes to go around and ask cows their ID numbers.

When a cow is asked their Farm ID number, they will start to say the correct bitstring, but may get confused and stop before finishing it. When Bessie hears the bitstring, if it is not the Farm ID number of any cow on the farm, then she will shrug and walk off. However, if it is the ID number of a different cow than the one she asked, then she will assume that identity theft has occurred and place the farm into lockdown. Note that this can happen even when the cow says their full Farm ID number.

Farmer John would like to prevent this from happening, and is willing to change the cows' Farm ID numbers by adding some more bits to them. In one second, he can add one bit to the end of the Farm ID number of any cow. Figure out the minimum amount of time it will take for him to prevent a lockdown from ever occurring.

입력

The first line contains NN, the number of cows on Farmer John's farm.

Then NN lines follow. The kkth line contains a bitstring equal to the Farm ID number of the kkth cow on Farmer John's farm.

No cow's Farm ID number is empty, and the total length of all Farm ID numbers is at most 10610^6.

출력

Output the minimum number of seconds Farmer John needs to spend to ensure that a lockdown will never occur.

예제 입력 1

3
1
1
1

예제 출력 1

5

예제 입력 2

3
1
11
111

예제 출력 2

2

예제 입력 3

3
1
1
11

예제 출력 3

4

예제 입력 4

5
0
01
0011
010
01

예제 출력 4

6

예제 입력 5

14
0
1
1
0
1
0
1
1
1
1
1
0
0
1

예제 출력 5

41

점수

Inputs 6-7: All Farm ID numbers have length exactly 11. Inputs 8-15: N102N\le 10^2 and the total length of the Farm ID numbers does not exceed 10310^3.Inputs 16-25: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.