Logo
(追記) (追記ここまで)

31763번 - Identity Theft 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB41222058.824%

문제

Farmer John's $N$ (1ドル \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 $N,ドル the number of cows on Farmer John's farm.

Then $N$ lines follow. The $k$th line contains a bitstring equal to the Farm ID number of the $k$th 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 10ドル^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

We can make a lockdown impossible in 5 seconds by adding '0' to the first Farm ID number, '10' to the second Farm ID number, and '11' to the third Farm ID number, making the Farm ID numbers '10', '110', and '111'.

You can prove that this cannot be done in 4 or fewer seconds. For example, if you leave the Farm ID numbers as they are, then all 3 cows have the same Farm ID number '1', so when Bessie hears it it will always be the Farm ID number of another cow.

As another example, if you spend just 2 seconds to add '0' to the second Farm ID number and '1' to the third Farm ID number, then the Farm ID numbers are '1', '10', and '11', and so the second and third cows, when saying their Farm ID numbers, might stop in the middle and just say '1', which would be the Farm ID number of the first cow.

예제 입력 2

3
1
11
111

예제 출력 2

2

We can make a lockdown impossible in 2 seconds by adding '0' to the first two Farm ID numbers, making the Farm ID numbers '10', '110', and '111' like before. You can prove that this cannot be done in 1 second.

예제 입력 3

3
1
1
11

예제 출력 3

4

We can make a lockdown impossible in 4 seconds by adding '00' to the first Farm ID number and '01' to the second Farm ID number. You can prove that this cannot be done in 3 or fewer seconds.

예제 입력 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

힌트

출처

Olympiad > USA Computing Olympiad > 2023-2024 Season > USACO 2024 US Open Contest > Platinum 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /