codeforces 590A A. Median Smoothing(思维)】的更多相关文章

题目链接: A. Median Smoothing time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia a…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the meth…
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…
B. Rebranding The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for the…
C. Median Smoothing   A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and e…
A. Median Smoothing time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article…
A. Median Smoothing time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article…
题目链接:http://codeforces.com/problemset/problem/590/A 题目大意是给一个串,头和尾每次变换保持不变. 中间的a[i]变成a[i-1],a[i],a[i+1]的中位数,而且此题串是01串. 对于01串 0 0 0中位数是0 0 0 1中位数是0 0 1 1中位数是1 1 1 1中位数是1 所以 1.串中有两个相邻以上的0或者1是保持不变的. 2.会变的只有是两个1中间的0或者两个0中间的1. 但是到这里的话,虽然证明了肯定能变成稳定态,就算把相同数字…
构造题. 答案可以o(n)构造出来.首先要发现规律.只有01交替的串才可能变化,变化规律如下: 1开头,长度为偶数(0结尾):变(len-2)/2次 变完后 前半1 后半01开头,长度为奇数(1结尾):变(len-1)/2次 变完后 全为10开头,长度为偶数(1结尾):变(len-2)/2次 变完后 前半0 后半10开头,长度为奇数(0结尾):变(len-1)/2次 变完后 全为0 然后就是在原串中寻找01交替串,然后按照上述规律进行变换. #include <cstdio> #include…
http://codeforces.com/problemset/problem/590/A: 在CF时没做出来,当时直接模拟,然后就超时喽. 题意是给你一个0 1串然后首位和末位固定不变,从第二项开始到倒数第二项,当前的a[i]=(a[i-1],a[i],a[i+1])三项排序后的中间项,比如连续3项为 1 0 1,那么中间的就变为1,然后题目让你输出达到稳定状态时所需的最小步数,不能的话输出-1. 无论给你啥数列,都能达到稳态.所以不可能输出-1: 还有一开始就稳定不变,或经过几次变换而稳定…