A15528 | SSeeeeiinngg DDoouubbllee
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
A palindrome is a string that reads the same backward as forward. For example, the strings $\texttt{z}$ , $\texttt{aaa}$ , $\texttt{aba}$ , and $\texttt{abccba}$ are palindromes, but $\texttt{codeforces}$ and $\texttt{ab}$ are not.
The double of a string $s$ is obtained by writing each character twice. For example, the double of $\texttt{seeing}$ is $\texttt{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.
The double of a string $s$ is obtained by writing each character twice. For example, the double of $\texttt{seeing}$ is $\texttt{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.
输入格式
The first line of input contains $t$ ( $1 \leq t \leq 1000$ ) — the number of test cases.
The only line of each test case contains a single string $s$ ( $1 \leq |s| \leq 100$ ) consisting only of lowercase English letters.
Note that the sum of $|s|$ over all test cases is not bounded.
The only line of each test case contains a single string $s$ ( $1 \leq |s| \leq 100$ ) consisting only of lowercase English letters.
Note that the sum of $|s|$ over all test cases is not bounded.
输出格式
For each test case, output a palindromic string of length $2 \cdot |s|$ that is a rearrangement of the double of $s$ .
输入输出样例
输入 #1
4 a sururu errorgorn anutforajaroftuna
输出 #1
aa suurruurruus rgnororerrerorongr aannuuttffoorraajjaarrooffttuunnaa
In the first test case, the double of $\texttt{a}$ is $\texttt{aa}$ , which is already a palindrome.
In the second test case, the double of $\texttt{sururu}$ is $\texttt{ssuurruurruu}$ . If we move the first $\texttt{s}$ to the end, we get $\texttt{suurruurruus}$ , which is a palindrome.
In the third test case, the double of $\texttt{errorgorn}$ is $\texttt{eerrrroorrggoorrnn}$ . We can rearrange the characters to form $\texttt{rgnororerrerorongr}$ , which is a palindrome.
In the second test case, the double of $\texttt{sururu}$ is $\texttt{ssuurruurruu}$ . If we move the first $\texttt{s}$ to the end, we get $\texttt{suurruurruus}$ , which is a palindrome.
In the third test case, the double of $\texttt{errorgorn}$ is $\texttt{eerrrroorrggoorrnn}$ . We can rearrange the characters to form $\texttt{rgnororerrerorongr}$ , which is a palindrome.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted