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

24832번 - Longest Palindrome 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 256 MB1451038771.901%

문제

Returning back to problem solving, Gildong is now studying about palindromes. He learned that a palindrome is a string that is the same as its reverse. For example, strings "pop", "noon", "x", and "kkkkkk" are palindromes, while strings "moon", "tv", and "abab" are not. An empty string is also a palindrome.

Gildong loves this concept so much, so he wants to play with it. He has $n$ distinct strings of equal length $m$. He wants to discard some of the strings (possibly none or all) and reorder the remaining strings so that the concatenation becomes a palindrome. He also wants the palindrome to be as long as possible. Please help him find one.

입력

The first line contains two integers $n$ and $m$ (1ドル \le n \le 100,ドル 1ドル \le m \le 50$) — the number of strings and the length of each string.

Next $n$ lines contain a string of length $m$ each, consisting of lowercase Latin letters only. All strings are distinct.

출력

In the first line, print the length of the longest palindrome string you made.

In the second line, print that palindrome. If there are multiple answers, print any one of them. If the palindrome is empty, print an empty line or don't print this line at all.

제한

예제 입력 1

3 3
tab
one
bat

예제 출력 1

6
tabbat

예제 입력 2

4 2
oo
ox
xo
xx

예제 출력 2

6
oxxxxo

예제 입력 3

3 5
hello
codef
orces

예제 출력 3

0

예제 입력 4

9 4
abab
baba
abcd
bcde
cdef
defg
wxyz
zyxw
ijji

예제 출력 4

20
ababwxyzijjizyxwbaba

노트

In the first example, "battab" is also a valid answer.

In the second example, there can be 4 different valid answers including the sample output. We are not going to provide any hints for what the others are.

In the third example, the empty string is the only valid palindrome string.

출처

Contest > Codeforces > Codeforces Round 620 (Div. 2) B번

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

출처

대학교 대회

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

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