0
点赞
收藏
分享

微信扫一扫

【寒假集训——cf题目翻译1】

Alex富贵 2022-01-17 阅读 34

题目一

A. Equidistant Letters

原题链接

原题在这里哦

原始题目

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.

Input
The first line contains a single integer t (1≤t≤103) — 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.

Output
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.

在这里插入图片描述

[题目翻译]

你被给予一个由小写拉丁字母组成的字符数组s。每个字母在字符串里面出现的次数不超过两次。
你的任务就是排列在字符数组里的字母,要求每一部分出现两次的字母之间的距离相同,不允许增加或移除字母。
可以知道结果总是存在的,如果有多种结果,打印任意一个即可。

输入

第一行包含一个整数t (1≤t≤103)—表示测试组数。
每一组测试数据都由一个含小写的拉丁字母组成的的不空的字符串数组,每一个字母在字符出里出现的次数不超过两次,字符串的长度不超过52.

输出

对于每一组测试样例,打印一个字符串,每一个字母出现的次数应该与原字符串中出现的次数相同,每一对出现两次的字母在字符串中间隔的距离要相同。
如果有多个答案,打印任意一个即可。

举报

相关推荐

0 条评论