637C.md (1885B)
1 Source: https://codeforces.com/problemset/problem/637/C 2 3 C. Promocodes with Mistakes 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 During a New Year special offer the "Sudislavl Bars" offered *n* promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ. 22 23 As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at as early as 6, many problems may arise as to how to type a promotional code without errors. It is necessary to calculate such maximum *k*, that the promotional code could be uniquely identified if it was typed with no more than *k* errors. At that, *k* = 0 means that the promotional codes must be entered exactly. 24 25 A mistake in this problem should be considered as entering the wrong numbers. For example, value "123465" contains two errors relative to promocode "123456". Regardless of the number of errors the entered value consists of exactly six digits. 26 27 Input 28 29 The first line of the output contains number *n* (1 ≤ *n* ≤ 1000) — the number of promocodes. 30 31 Each of the next *n* lines contains a single promocode, consisting of exactly 6 digits. It is guaranteed that all the promocodes are distinct. Promocodes can start from digit "0". 32 33 Output 34 35 Print the maximum *k* (naturally, not exceeding the length of the promocode), such that any promocode can be uniquely identified if it is typed with at most *k* mistakes. 36 37 Examples 38 39 Input 40 41 ``` 42 2 43 000000 44 999999 45 ``` 46 47 Output 48 49 ``` 50 2 51 ``` 52 53 Input 54 55 ``` 56 6 57 211111 58 212111 59 222111 60 111111 61 112111 62 121111 63 ``` 64 65 Output 66 67 ``` 68 0 69 ``` 70 71 Note 72 73 In the first sample *k* < 3, so if a bar customer types in value "090909", then it will be impossible to define which promocode exactly corresponds to it.