英语题目翻译

题目地址:https://acs.jxnu.edu.cn/contest/24/board/challenge/A

ABC

描述:

Recently, the students of School 179 have developed a unique algorithm, which takes in a binary string ss as input. However, they soon found out that if some substring tt of ss is a palindrome of length greater than 1, the algorithm will work incorrectly. Can the students somehow reorder the characters of ss so that the algorithm will work correctly on the string?

最近,179学校的学生开发了一种独特的算法,将二进制字符串ss作为输入。然而,他们很快发现,如果ss的某个子串tt是长度大于1的回文,算法将无法正常工作。学生们能否以某种方式重新排列ss的字符,以便算法能正确地处理字符串?

A binary string is a string where each character is either 0 or 1.

一个二进制的字符串是有0或者1组成的。

A string aa is a substring of a string bb if aa can be obtained from bb by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.

字符串aa是字符串bb的子字符串,如果aa可以通过删除开头的几个(可能是零或全部)字符和结尾的几个(可能是零或全部)字符从bb中获得。

A palindrome is a string that reads the same backwards as forwards.

回文是一个字符串从前边和后边读都一样。

输入:

Each test contains multiple test cases. The first line contains the number of test cases  (1≤t≤100). Description of the test cases follows.

每个测试包含多个测试用例。第一行包括测试样例的数量。测试用例的描述如下。

The first line of each test case contains a single integer n(1≤n≤100) — the length of the string s.

每个测试样例的第一行包括一个整数n(1≤n≤100)--字符串的长度。

The second line of each test case contains the string s of length n consisting only of the characters 0 and 1.

每个测试样例的第二行包括长度为n的字符串s,每个字符串由0和1组成。

输出:

For each test case, print YES (case-insensitive) if it is possible to reorder the characters of s so that there are no substrings that are a palindrome of length greater than 1, or NO (case-insensitive) otherwise.

对于每个测试用例,如果可以对s的字符进行重新排序,以便不存在长度大于1的回文子字符串,则打印“是”(不区分大小写),否则打印“否”(不区分大小写)。

样例输入:

4
1
1
2
10
2
01
4
1010

复制

样例输出:

YES
YES
YES
NO
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值