309110: CF1626A. Equidistant Letters
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Equidistant Letters
题意翻译
### 题目描述 给定一个字符串 $s$,由小写字母组成。每个字母在字符串中出现不超过两次。 您的任务是重新排列字符串中的字母,使每对相同字母之间的的距离相等。不允许添加或删除字母。 可以证明答案总是存在的。如果有多个答案,请打印其中任何一个。 ### 输入格式 第一行包含一个整数 $t$ $(1\le t\le 10^3,1 \le T \le 10)$,为测试用例的数量。 每个测试用例由一个非空字符串 $s$ 组成,由小写拉丁字母组成。每个字母在字符串中出现的次数不超过两次。字符串的长度不超过52。 ### 输出格式 对于每个测试用例,打印一个字符串。每个字母在其中出现的次数应与在字符串 $s$ 中出现的次数相同。对于恰好出现两次的每一对字母,该对字母之间的距离应全部相同。 如果有多个答案,请打印其中任何一个。题目描述
You are given a string $ s $ , consisting of lowercase Latin letters. Every letter appears in it no more than twice. Your task is to rearrange the letters in the string in such a way that for each pair of letters that appear exactly twice, the distance between the letters in the pair is the same. You are not allowed to add or remove letters. It can be shown that the answer always exists. If there are multiple answers, print any of them.输入输出格式
输入格式
The first line contains a single integer $ t $ ( $ 1 \le t \le 10^3 $ ) — the number of testcases. Each testcase consists of a non-empty string $ s $ , consisting of lowercase Latin letters. Every letter appears in the string no more than twice. The length of the string doesn't exceed $ 52 $ .
输出格式
For each testcase, print a single string. Every letter should appear in it the same number of times as it appears in string $ s $ . For each pair of letters that appear exactly twice, the distance between the letters in the pair should be the same. If there are multiple answers, print any of them.
输入输出样例
输入样例 #1
3
oelhl
abcdcba
ac
输出样例 #1
hello
ababcdc
ac