欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1073A.Diverse Substring
Diverse Substring
You are given a string , consisting of lowercase Latin letters.
A substring of string is a continuous segment of letters from . For example, "defor" is a substring of "codeforces" and "fors" is not.
The length of the substring is the number of letters in it.
Let's call some string of length diverse if and only if there is no letter to appear strictly more than times. For example, strings "abc" and "iltlml" are diverse and strings "aab" and "zz" are not.
Your task is to find any diverse substring of string or report that there is none. Note that it is not required to maximize or minimize the length of the resulting substring.
Input
The first line contains a single integer () — the length of string .
The second line is the string , consisting of exactly lowercase Latin letters.
Output
Print "NO" if there is no diverse substring in the string .
Otherwise the first line should contain "YES". The second line should contain any diverse substring of string .
Note
The first example has lots of correct answers.
Please, restrain yourself from asking if some specific answer is correct for some specific test or not, these questions always lead to "No comments" answer.
Samples
10
codeforces
YES
code
5
aaaaa
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |