QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 512 MB 満点: 100

#9328. 构造回文串

統計

你有一个由小写英文字母组成的字符串 $s$。你希望通过执行零次或多次操作将其转换为回文串。在一次操作中,你可以交换字符串中距离恰好为 2 的任意两个字符(换句话说,这两个字符之间恰好有一个字符)。

请判断是否可以将字符串 $s$ 转换为回文串。

回文串是指与自身反转后的字符串相同的字符串。

输入格式

第一行包含一个整数 $t$ ($1 \le t \le 10^5$),表示测试用例的数量。接下来是各测试用例。

每个测试用例的第一行包含一个整数 $n$ ($1 \le n \le 10^5$)。第二行包含长度为 $n$ 的字符串 $s$,由小写英文字母组成。

所有测试用例的 $n$ 之和不超过 $10^5$。

输出格式

对于每个测试用例,如果可以通过给定的规则将字符串转换为回文串,则输出一行 "YES",否则输出 "NO"。

样例

输入格式 1

8
6
acbbca
6
acbbac
6
aaaaaa
7
abcacba
9
abcbcecea
1
b
2
ca
2
cc

输出格式 1

YES
NO
YES
YES
YES
YES
NO
YES

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.