codeforces 1015E1&&E2】的更多相关文章

E1. Stars Drawing (Easy Edition) time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output A star is a figure of the following type: an asterisk character '*' in the center of the figure and four ra…
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(…
题面: 传送门 题目描述: 要求用十字星星来画题目给出的"星"图.如果不能用十字星星来画"星"图,输出-1:如果能,则输出要在图的哪个位置画相应大小的十字星图.   题目分析: 这道题纯属模拟题,按照要求画就好了.我的画法:根据题目的"星"图用十字星图在另一个二维数组画"星"图.拿第一个样例来说:当遍历到第一颗星星,我就会检查是否能用十字星星去按题目给出的"星图"填充: 显然,第一个星星不能用十字星星去画图…
Codeforces 1108E2 E2. Array and Segments (Hard version) Description: The only difference between easy and hard versions is a number of elements in the array. You are given an array \(a\) consisting of \(n\) integers. The value of the \(i\)-th element…
传送门:http://codeforces.com/contest/1108/problem/E2 E2. Array and Segments (Hard version) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The only difference between easy and hard versions i…
题目:http://codeforces.com/problemset/problem/391/E2    题意:有三棵树.每棵树有ni个结点,加入两条边把这三棵树连接起来,合并成一棵树.使得合并的树中随意两点之间的最短路径    的和最大. 分析:    三棵树要合并成一棵树,则第一棵树必须选择一个点,如果为X.第二棵树必须选择两个点,如果为Y1, Y2,第三棵树必须选择一个点,如果为Z    记第一棵树中全部结点到X的路径总和为:tot1    第二棵树中全部结点到Y1,Y2的路径总和分别为…
参考:http://www.cnblogs.com/widsom/p/9290269.html 传送门:http://codeforces.com/contest/1005/problem/E2 题意:求一段数列中,取其中中位数为m的子序列个数有几个: 思路:首先我们可以先求出——序列中大于等于 m的数占多数的子序列——有多少个.然后,再求出序列中大于等于m+1的数占多数的子序列有多少个. 前面序列的个数减去后面的序列个数,就是答案. 显然这两个个数的求法是一样的.具体来说, 因为要计算区间的大…
链接: https://codeforces.com/contest/1209/problem/E2 题意: This is a harder version of the problem. The difference is only in constraints. You are given a rectangular n×m matrix a. In one move you can choose any column and cyclically shift elements in th…
https://codeforces.com/contest/1181/problem/E2 想到了划分的方法跟题解一样,但是没理清楚复杂度,很难受. 看了题解觉得很有道理,还是自己太菜了. 然后直接开始写,四个if写的太难受了180+行. ac之后看了红名大佬的代码,简直woc,好短,四个sort我分开写了,但是红名大佬写的很巧妙,借鉴了一下代码长度缩短到110行左右,红名大佬np,特此记录. 使用静态链表,复杂度计算 T(n) = T(a1)+T(a2)+T(a3) ... + O(nlog…
(easy version): 题目链接:http://codeforces.com/contest/1296/problem/E1 题目一句话就是说,两种颜色不同的字符可以相互换位, 问,对这字符串用最多两种颜色染色,然后经过有限次换位 可以变成字典序排序的顺序. 思路:一个字符需不需要换位,应该是参照最后的字典序的顺序, 那么,我们应该给字符串排序,再去思考问题. 我们知道,如果str[now_i]的位置和排序后的位置不一样,那就是需要换位. 我们还知道,如果str[now_i]的当前位置如…