codeforces 166C Median - from lanshui_Yang】的更多相关文章

C. Median time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A median in an array with the length of n is an element which occupies position number  after we sort the elements in the non-decr…
题目链接: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…
其实自己只会做很简单的题,有时都不想写解题报告,觉得不值得一写,但是又想到今后也许就不会做ACM了,能留下来的东西只有解题报告了,所以要好好写,很渣的题也要写,是今后的纪念. B - B Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 313A Description Ilya is a very clever lion,…
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…
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…
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…
题目链接: 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…
You are given two strings ss and tt, both consisting of exactly kk lowercase Latin letters, ss is lexicographically less than tt. Let's consider list of all strings consisting of exactly kk lowercase Latin letters, lexicographically not less than ss …
E2 - Median on Segments (General Case Edition) 思路: 首先我们计算出solve(m):中位数大于等于m的方案数,那么最后答案就是solve(m) - solve(m+1) 那么怎么计算sovle(m)呢? 对于一个区间[l,r],如果它的中位数大于等于m,那么这个区间中 (大于等于m的数的个数) > (小于m的数的个数) 如果记a[i]大于等于m为+1,小于m 为 -1,即 sum(l, r)  > 0 我们枚举右端点 i ,并且同时计算sum(…