HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN303 2013-15 Questions > problem:


15PrE-40. 50819 - Linked Numbers

CEN303 2013-15 Questions

Start: Dec.15.2013 at 02:00:00 PM
Finish: Dec.15.2013 at 07:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (2)

Contest problems

• 15HW-50. 50830 - Sorting BST Nodes
• 15HW-60. 50678 - The Jumping Rabbit
• 15MdE-10. 50802 - Comparing Exams
• 15MdE-20. 50803 - Sum of the dept...
• 15MdE-40. 50805 - Sum of the weig...
• 15PrE-10. 50816 - Largest Sum Path
• 15PrE-20. 50817 - The Knight Move
• 15PrE-30. 50818 - Depth Limited BST
• 15PrE-40. 50819 - Linked Numb...
• 15PrE2-01. 50847 - The first m train...
• 15PrE2-06. 50837 - Sum is equal to K
• 15Rst-10. 50857 - Nine-Stones Game
• 2.15FE-03. 50996 - Checkers - the ...

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Linked Numbers

Assume that you are given the n numbers. Find the maximum length of number ordering such that the last digit of one number (an) is the same as the first digit of the next number (an+1). For example the following series complies the Linked Numbers property:

  12 235 514 
However the following series does not:
   12 235 415 
because second number 235 ends with 5, but the third number 415 starts with 4.

Question: You will be given n positive integer. By possible replacements, find the length of longest linked numbers.

Input specification
In the first line, you will be given a number: The number of numbers(n) 1 ≤ n ≤ 30. Then, in the following n lines, you will be given n integers which are between 0 and 12,000.

Output specification
Show the length of the longest linked list

Sample Input
4
235
12
317
514
Sample Output
3



Для отправки решений необходимо выполнить вход.

www.contester.ru