1165C.md (1350B)
1 Source: https://codeforces.com/problemset/problem/1165/C 2 3 C. Good String 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 Let's call (yet again) a string good if its length is even, and every character in odd position of this string is different from the next character (the first character is different from the second, the third is different from the fourth, and so on). For example, the strings good, string and xyyx are good strings, and the strings bad, aa and aabc are not good. Note that the empty string is considered good. 22 23 You are given a string $s$, you have to delete minimum number of characters from this string so that it becomes good. 24 25 Input 26 27 The first line contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of characters in $s$. 28 29 The second line contains the string $s$, consisting of exactly $n$ lowercase Latin letters. 30 31 Output 32 33 In the first line, print one integer $k$ ($0 \le k \le n$) — the minimum number of characters you have to delete from $s$ to make it good. 34 35 In the second line, print the resulting string $s$. If it is empty, you may leave the second line blank, or not print it at all. 36 37 Examples 38 39 Input 40 41 ``` 42 4 43 good 44 ``` 45 46 Output 47 48 ``` 49 0 50 good 51 ``` 52 53 Input 54 55 ``` 56 4 57 aabc 58 ``` 59 60 Output 61 62 ``` 63 2 64 ab 65 ``` 66 67 Input 68 69 ``` 70 3 71 aaa 72 ``` 73 74 Output 75 76 ``` 77 3 78 ```