CF1758A.SSeeeeiinngg DDoouubbllee

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A palindrome is a string that reads the same backward as forward. For example, the strings z\texttt{z} , aaa\texttt{aaa} , aba\texttt{aba} , and abccba\texttt{abccba} are palindromes, but codeforces\texttt{codeforces} and ab\texttt{ab} are not.

The double of a string ss is obtained by writing each character twice. For example, the double of seeing\texttt{seeing} is sseeeeiinngg\texttt{sseeeeiinngg} .

Given a string ss , rearrange its double to form a palindrome. Output the rearranged string. It can be proven that such a rearrangement always exists.

输入格式

The first line of input contains tt ( 1t10001 \leq t \leq 1000 ) — the number of test cases.

The only line of each test case contains a single string ss ( 1s1001 \leq |s| \leq 100 ) consisting only of lowercase English letters.

Note that the sum of s|s| over all test cases is not bounded.

输出格式

For each test case, output a palindromic string of length 2s2 \cdot |s| that is a rearrangement of the double of ss .

输入输出样例

  • 输入#1

    4
    a
    sururu
    errorgorn
    anutforajaroftuna

    输出#1

    aa
    suurruurruus
    rgnororerrerorongr
    aannuuttffoorraajjaarrooffttuunnaa

说明/提示

In the first test case, the double of a\texttt{a} is aa\texttt{aa} , which is already a palindrome.

In the second test case, the double of sururu\texttt{sururu} is ssuurruurruu\texttt{ssuurruurruu} . If we move the first s\texttt{s} to the end, we get suurruurruus\texttt{suurruurruus} , which is a palindrome.

In the third test case, the double of errorgorn\texttt{errorgorn} is eerrrroorrggoorrnn\texttt{eerrrroorrggoorrnn} . We can rearrange the characters to form rgnororerrerorongr\texttt{rgnororerrerorongr} , which is a palindrome.

首页