CF1758A.SSeeeeiinngg DDoouubbllee

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

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.

回文串是指正读和反读都相同的字符串。例如,字符串 z\texttt{z}、aaa\texttt{aaa}、aba\texttt{aba} 和 abccba\texttt{abccba} 是回文串,但 codeforces\texttt{codeforces} 和 ab\texttt{ab} 不是。

字符串 ss 的“双倍串”是将 ss 中每个字符重复两次所得到的字符串。例如,seeing\texttt{seeing} 的双倍串为 sseeeeiinngg\texttt{sseeeeiinngg}。

给定一个字符串 ss,请重排其双倍串,使其成为一个回文串,并输出该重排后的字符串。可以证明这样的重排总是存在的。

输入格式

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

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

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

输入的第一行包含一个整数 tt(1≤t≤10001 \leq t \leq 1000),表示测试用例的数量。

每个测试用例仅有一行,包含一个字符串 ss(1≤∣s∣≤1001 \leq |s| \leq 100),该字符串仅由小写英文字母组成。

注意:所有测试用例的 ∣s∣|s| 之和没有上界。

输出格式

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

对于每个测试用例,输出一个长度为 2⋅∣s∣2 \cdot |s| 的回文字符串,该字符串是 ss 的两倍(即 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.

在第一个测试用例中,字符串 a\texttt{a} 的双倍字符串为 aa\texttt{aa},它本身就是一个回文串。

在第二个测试用例中,字符串 sururu\texttt{sururu} 的双倍字符串为 ssuurruurruu\texttt{ssuurruurruu}。若将开头的 s\texttt{s} 移至末尾,可得到 suurruurruus\texttt{suurruurruus},它是一个回文串。

在第三个测试用例中,字符串 errorgorn\texttt{errorgorn} 的双倍字符串为 eerrrroorrggoorrnn\texttt{eerrrroorrggoorrnn}。我们可以重新排列这些字符,得到回文串 rgnororerrerorongr\texttt{rgnororerrerorongr}。

输入解题思路,AI测评打分。不知道怎么写?

首页