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, aaa, aba, and abccba are palindromes, but codeforces and ab are not.
The double of a string s is obtained by writing each character twice. For example, the double of seeing is sseeeeiinngg.
Given a string s, rearrange its double to form a palindrome. Output the rearranged string. It can be proven that such a rearrangement always exists.
回文串是指正读和反读都相同的字符串。例如,字符串 z、aaa、aba 和 abccba 是回文串,但 codeforces 和 ab 不是。
字符串 s 的“双倍串”是将 s 中每个字符重复两次所得到的字符串。例如,seeing 的双倍串为 sseeeeiinngg。
给定一个字符串 s,请重排其双倍串,使其成为一个回文串,并输出该重排后的字符串。可以证明这样的重排总是存在的。
输入格式
The first line of input contains t (1≤t≤1000) — the number of test cases.
The only line of each test case contains a single string s (1≤∣s∣≤100) consisting only of lowercase English letters.
Note that the sum of ∣s∣ over all test cases is not bounded.
输入的第一行包含一个整数 t(1≤t≤1000),表示测试用例的数量。
每个测试用例仅有一行,包含一个字符串 s(1≤∣s∣≤100),该字符串仅由小写英文字母组成。
注意:所有测试用例的 ∣s∣ 之和没有上界。
输出格式
For each test case, output a palindromic string of length 2⋅∣s∣ that is a rearrangement of the double of s.
对于每个测试用例,输出一个长度为 2⋅∣s∣ 的回文字符串,该字符串是 s 的两倍(即 s 与其自身的拼接)的一个重排。
输入输出样例
输入#1
4 a sururu errorgorn anutforajaroftuna
输出#1
aa suurruurruus rgnororerrerorongr aannuuttffoorraajjaarrooffttuunnaa
说明/提示
In the first test case, the double of a is aa, which is already a palindrome.
In the second test case, the double of sururu is ssuurruurruu. If we move the first s to the end, we get suurruurruus, which is a palindrome.
In the third test case, the double of errorgorn is eerrrroorrggoorrnn. We can rearrange the characters to form rgnororerrerorongr, which is a palindrome.
在第一个测试用例中,字符串 a 的双倍字符串为 aa,它本身就是一个回文串。
在第二个测试用例中,字符串 sururu 的双倍字符串为 ssuurruurruu。若将开头的 s 移至末尾,可得到 suurruurruus,它是一个回文串。
在第三个测试用例中,字符串 errorgorn 的双倍字符串为 eerrrroorrggoorrnn。我们可以重新排列这些字符,得到回文串 rgnororerrerorongr。
输入解题思路,AI测评打分。不知道怎么写?