HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Unsorted > problem:


50819 - Linked Numbers

Guest
• Review clarifications (2)

Section problems

• 51004 - Word Search Game
• 50430 - ATM
• 50489 - Football Championship
• 50391 - Cinema Tickets
• 50820 - Post Office
• 50810 - Print Office
• 50952 - Derby Tirana
• 50443 - Dajte Express
• 50819 - Linked Numbers
• 50519 - Image Filtering
• 50798 - Passing the course
• 50799 - OSHEE Electric Bill
• 50833 - Min of Odd Positions
• 50821 - Derivative of an array
• 50808 - Total Distance Traveled
• 50817 - The Knight Move
• 50537 - esreveR Triangle

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