Answer
Time limit2sMemory limit1024 MB
Find three distinct numbers from the list that, concatenated in some order, form a palindrome with no leading zeros.
- Level
Medium5 of 10
- Topics
- String, Brute force, Hash map
- Solved
- No attempts yet
Problem
Many people did not believe that the answer to the ultimate question of life, the universe, and everything is 42. Big Computer was upset by this, so it tried to find the answer again. It built another computer, which produced a list of natural numbers. No two numbers in the list are equal.
Big Computer decided that if the list contains three different numbers that, written one after another, form a palindrome (a number that reads the same from left to right and from right to left), then the answer is that palindrome. Leading zeros in the palindrome are not allowed.
Suddenly a cartoon that is very interesting to Big Computer came on television, so it asked you to solve this problem.
Input
The first line of the input file contains one natural number (), the count of generated numbers. The second line contains the numbers themselves. All numbers are pairwise distinct, positive integers, and do not exceed .
Output
Print on a single line, separated by spaces, the three numbers whose concatenation forms the palindrome. If there are several answers, print any of them. If no answer exists, print <<Sorry, but I don't know answer!>>.