Vasya has a string s of length n. He decides to make the following modification to the string: Pick an integer k, (1≤k≤n). For i from 1 to n−k+1, reverse the substring s[i:i+k−1] of s. For example, if string s is qwer and k=2, below is the series of…
题意:有一个长度为\(n\)的字符串,你可以选取一个值\(k(1\le k \le n)\),然后遍历字符串,每次将区间长度为\(k\)的字符串反转,求反转后字典序最小的字符串,并输出\(k\)的值. 题解:这题我是打表找规律写的,观察样例不难发现,当区间长度为\(k\)时,答案字符串就是将前\(k-1\)个字符移到了尾部,并且,假如\(k\)的奇偶性和\(n\)相同,那么这前\(k-1\)个字符就要反转,所以我们只要遍历\(k\),然后模拟维护一个字典序最小的字符串即可. 代码: int t;…
C. Median Smoothing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem/C Description A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that des…