1073A.md (1575B)
1 Source: https://codeforces.com/problemset/problem/1073/A 2 3 A. Diverse Substring 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You are given a string $s$, consisting of $n$ lowercase Latin letters. 22 23 A substring of string $s$ is a continuous segment of letters from $s$. For example, "defor" is a substring of "codeforces" and "fors" is not. 24 25 The length of the substring is the number of letters in it. 26 27 Let's call some string of length $n$ diverse if and only if there is no letter to appear strictly more than $\frac n 2$ times. For example, strings "abc" and "iltlml" are diverse and strings "aab" and "zz" are not. 28 29 Your task is to find any diverse substring of string $s$ or report that there is none. Note that it is not required to maximize or minimize the length of the resulting substring. 30 31 Input 32 33 The first line contains a single integer $n$ ($1 \le n \le 1000$) — the length of string $s$. 34 35 The second line is the string $s$, consisting of exactly $n$ lowercase Latin letters. 36 37 Output 38 39 Print "NO" if there is no diverse substring in the string $s$. 40 41 Otherwise the first line should contain "YES". The second line should contain any diverse substring of string $s$. 42 43 Examples 44 45 Input 46 47 ``` 48 10 49 codeforces 50 ``` 51 52 Output 53 54 ``` 55 YES 56 code 57 ``` 58 59 Input 60 61 ``` 62 5 63 aaaaa 64 ``` 65 66 Output 67 68 ``` 69 NO 70 ``` 71 72 Note 73 74 The first example has lots of correct answers. 75 76 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.