自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(81)
  • 收藏
  • 关注

原创 codeforces Round #258(div2) D解题报告

题目大意:给出一串字符,只含有a和b。现在定义一个字串如若合并之后的字串是个回文字符串,就是一个good substrings,求出这样的字串有多少个,并输出长度为偶数和奇数的个数。解法:首先,我们需要注意到两个已知条件: 1. 字串可以合并,例如 abbaabbb 合并之后就是abab 2. 只有两个字符a,b我们可以发现,合并之后的字串一定是aba或者abab类型的,那么合并之后的字串如果是回文的话,第一个字符肯定与最后一个字符相同,反之亦然。我们可以进一步

2014-10-28 17:28:09 914 3

原创 codeforces Round #258(div2) C解题报告

题目大意: 有n场比赛,你错过了k场,然后再错过的k长中,一队与二队的胜利差值为d1,二队与三队的胜利差值为d2。如若有可能,三支队伍获胜次数都一样,则输出yes,否则输出no解法: 比较有趣且复杂的模拟题,我们可以想象成三个柱子,已知第一个柱子跟第二个柱子的高度差的绝对值,第二个柱子跟第三个柱子高度差的绝对值,现在还有n-k个砖(1高度),要求使得三个柱子高度一样。首先,给了d1和d2,我们可以枚举一下有那几种基本情况: 1. d1, 0, d2;

2014-10-28 17:18:12 1012

原创 codeforces Round #258(div2) B解题报告

B. Sort the Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBeing a programmer, you like arrays a lot.

2014-10-28 17:06:14 791

原创 codeforces Round #258(div2) A解题报告

A. Game With Stickstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter winning gold and silver in IOI 201

2014-10-28 17:01:03 769

原创 codeforces Round #275(div2) B解题报告

B. Friends and Presentstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have two friends. You want to pr

2014-10-27 21:17:15 868

原创 codeforces Round #275(div2) D解题报告

题目大意:假设有n个非负数,现在有m个限制,a[l] & a[l+1] & a[l+2] ... & a[r] = q。要求根据上述的限制,输出符合要求的1~n个数,如若不能则输出“NO”。解法: 我们先挖掘题意,弄清楚题目给的已知条件和要我们输出什么。 a[l] & a[l+1] & a[l+2] ... & a[r] = q,这是每个限制的基本形式,由“&”我们可以得知,如若q中的某一个bit是1的话,则要求a[l]~a[r]中的那个bit位都为1。这个条件看似是限制

2014-10-27 21:08:08 1162

原创 codeforces Round #275(div2) C解题报告

C. Diverse Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPermutation p is an ordered set of in

2014-10-27 20:58:31 818

原创 codeforces Round #275(div2) A解题报告

A. Counterexampletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYour friend has recently learned about cop

2014-10-27 20:53:43 788

原创 codeforces Round #259(div2) E解题报告

题目大意:给出一张图,有N个点,M条边,并给出每个点要求访问次数的奇偶性。,要求输出访问路径。解法:首先我们可以明确一点,这就是一个图的遍历,找一个点,设为起点,建立一个搜索遍历树,对于树每一个点,我们完全可以控制奇偶性,假设: 目前访问的点为v,父节点为fa,如若点v不符合当前的奇偶性,则就让父节点到v绕一次,这样 odd[v] ^= 1, fa[v] ^= 1,这样我们可以完全保证完全控制子节点,将不符合要求的奇偶性调整成符合要求的奇偶性。同时父节点的奇偶性也在改变。

2014-10-24 20:02:20 954

原创 codeforces Round #259(div2) D解题报告

题目大意:给出N个数ai,求出另一个序列bi,要求sum |ai-bi|,最短,且所有的bi都互质。解法:这里题目给了几个很显眼的条件,ai限制在了1~30之间,由于可以bi无限选1这个数,那么|ai-bi| 最大就是29了,意味着bi < 59的。要求所有的bi互质,可以化为所有的bi分解出来的质因数均不相同,bi < 59,有16个质数。这里我们很容易联想到状态压缩DP了。用s表示当前阶段用了哪些质因数的状态,例如 s = 3 = 11 代表目前状态下使用了第一个和第二个质因数。很快我们

2014-10-24 19:40:51 998

原创 codeforces Round #259(div2) C解题报告

题目大意:一个m个面的骰子,抛掷n次,求这n次里最大值的期望是多少。解法:数学题,有m个面的骰子,抛n次,那么总共的情况就有m^n。我们从m=1开始推起。m = 1, 只有一种情况,m = 2,新增了2^n-1^n种情况,这些新增的情况里面,最大值均是 2,m = 3,新增了3^n-2^n种情况,这些新增的情况里面,最大值均是 3,我们就可以推出数学期望公式: ans = 1/(m^n) * [1 + (2^n-1^n)*2 + (3^n-2^n)*3 .... + (m^n - (m-

2014-10-24 19:27:50 1003

原创 codeforces Round #259(div2) B解题报告

题目大意:给出N个数字,可以每一次将最后一个数字移动到最前面,要求最终状态是一个单调非递减的序列,求最少需要花多少次操作。如若无法达到目标则输出“-1"。解法:也是一道很easy的编程基础题,找出两队单调非递减序列,分别为1~x 和 x+1~y,判断这两队是否覆盖整串数字,且a[n] <= a[1]。更简单的一种做法就是,将a[1]~a[n]复制一遍,拓展到a[1]~a[2*n],然后在1 ~ 2*n里面找,是否有一串单调不递减的个数为n的序列。

2014-10-24 19:11:17 927

原创 codeforces Round #259(div2) A解题报告

A. Little Pony and Crystal Minetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwilight Sparkle once got a

2014-10-24 19:02:10 661

原创 codeforces Round #260(div2) D解题报告

首先存这些字符,用trie来存,通过trie就很容易联想到树型DP,这里的DP就不是取最优值之类的了,而是用来弄到达某个节点的胜负情况。我们首先设节点v,win[v]代表已经组装好的字符刚好匹配到v了,然后需要进行下一步匹配时,先手是否可以赢,lose[v]则代表先手是否会输。叶节点,win[v] = false, lose[v] = true.其他节点 win[v] = win[v] | !win[child], lose[v] = lose[v] | !lose[child]. (因为每次赢的

2014-10-23 21:40:22 954

原创 codeforces Round #260(div2) E解题报告

E. Civilizationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndrew plays a game called "Civilization". D

2014-10-23 21:39:17 747

原创 codeforces Round #260(div2) C解题报告

C. Boredomtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlex doesn't like boredom. That's why whenever he

2014-10-23 21:15:24 799

原创 codeforces Round #260(div2) B解题报告

B. Fedya and Mathstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFedya studies in a gymnasium. Fedya's mat

2014-10-23 21:07:13 619

原创 codeforces Round #260(div2) A解题报告

A. Laptopstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Dima and Alex had an argument about the p

2014-10-23 21:06:47 712

原创 codeforces Round #261(div2) E解题报告

E. Pashmak and Graphtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPashmak's homework is a problem about g

2014-10-22 22:10:35 778

原创 codeforces Round #261(div2) D解题报告

我们可以通过预处理,在O(n)之内,算出f(1, i, a[i]) 定义数组为l[i], 算出f(j, n, a[j]) 定义数组为r[i]。题目就转化为:求出 l[i] > r[j] (i < j)。本质上,就是一个求逆序对的做法,用树状数组。

2014-10-22 22:00:53 691

原创 codeforces Round #261(div2) C解题报告

把这题抽象一下,每个人,在1~K个数中选数字,组成d长度的序列,要求每个序列不能完全相同,数字可以重复选。进一步抽象一下,每个人的乘坐公交的序列,就是d位k进制数,最多可以分配的序列个数为 k^d。如若 n <= k^d,则从0(k进制),每次+1输出,反之没有答案。举个例子进一步说说明: n = 8, k = 3, d = 4。 这里的0表示标记为1的公交,1为标记为2的公交,以此类推 第一个人的序列: 0, 0, 0, 0 第二个人的序列: 0, 0,

2014-10-22 21:58:14 597

原创 codeforces Round #261(div2) B解题报告

B. Pashmak and Flowerstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPashmak decided to give Parmida a pai

2014-10-22 21:41:54 636

原创 codeforces Round #261(div2) A解题报告

A. Pashmak and Gardentime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPashmak has fallen in love with an att

2014-10-22 21:39:48 738

原创 codeforces Round #274(div2) E解题报告

首先明确一点,如若a < b,则无论如何都不可能乘坐到大于b的那一部分,反之亦然。 采用动态规划策略,这里我们可以以i为乘坐了i次,j为哪一层电梯。f[i][j] = sum(f[i-1][m]) - f[i-1][j],这里的m为满足条件的上一个楼层(设上一个楼层为x |x-j| < |x-b| )。这里的时间复杂度为O(k*n*n); 我们可以发现,m为一段连续区间,我们就可以用sum先累积起来,这里就直接简化为O(1),总的时间复杂度为O(k*n)。(PS: 注意m的边界)

2014-10-20 12:22:42 806 2

原创 codeforces Round #274(div2) D解题报告

这题,我们必然需要查询某个数,这里我们可以让ai单调(题目已经预设是单调的),然后采用二分来查询,这样,每次查询只需要O(logn)的时间复杂度,这是本题的基本的核心。由题意可知,标记增加量可能为:0, 1, 2;为0个的时候: 则x和y都可以在尺子上找到,即a[i]+x和a[i]+y均可在尺子上找到,我们可以采用二分搜索。复杂度为O(nlogn);为1个的时候: 第一种情况:x或y其中一个可以在尺子上找到; 第二种情况:可以找到组合点,即 a[i]+

2014-10-20 12:13:40 1093 2

原创 codeforces Round #274(div2) C解题报告

C. Examstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputStudent Valera is an undergraduate student at the U

2014-10-20 12:08:48 678

原创 codeforces Round #274(div2) B解题报告

B. Towerstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you know, all the kids in Berland love playing

2014-10-20 11:57:19 713

原创 codeforces Round #274(div2) A解题报告

A. Expressiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya studies in a school and he adores Maths.

2014-10-20 11:54:32 692

原创 codeforces Round #273(div2) D解题报告

D. Red-Green Towerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are r red and g green blocks for

2014-10-18 21:28:17 671

原创 codeforces Round #273(div2) C解题报告

C. Table Decorationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have r red, g green and b blue ba

2014-10-18 21:20:21 606

原创 codeforces Round #273(div2) B解题报告

B. Random Teamstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputn participants of the competition were split

2014-10-18 21:12:07 541

原创 codeforces Round #273(div2) A解题报告

A. Initial Bettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are five people playing a game called "

2014-10-18 21:06:23 558

原创 codeforces Round #263(div2) E解题报告

E. Appleman and a Sheet of Papertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAppleman has a very big sh

2014-10-17 12:13:52 193

原创 codeforces Round #263(div2) D解题报告

很典型的树形dp了。第一步,明确问题的类型:计数型DP,并非最大值或最小值DP,考虑到其结构是一个树形,很容易联想到树形DP。第二步,划分阶段和状态:阶段为v,即为每个节点;状态为s,即为包括节点v以内的子树内有无黑节点,1表示有1个黑节点,0表示没有黑节点。第三步,由于是计数型DP,就得明确先明确计数原理:乘法原理与加法原理相结合。乘法原理:用于v节点的所有child节点中,整个v节点有多少种方案,需要通过所有child节点,如果标上顺序(结果与访问child顺序无关,所以怎样的合法顺序都

2014-10-17 12:04:44 661

原创 codeforces Round #263(div2) C解题报告

C. Appleman and Toastmantime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAppleman and Toastman play a game.

2014-10-17 11:51:55 669

原创 codeforces Round #263(div2) B解题报告

B. Appleman and Card Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAppleman has n cards. Each card

2014-10-17 11:34:39 535

原创 codeforces Round #263(div2) A解题报告

A. Appleman and Easy Tasktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToastman came up with a very easy

2014-10-17 11:31:35 726

原创 codeforces Round #264(div2) E解题报告

E. Caisa and Treetime limit per test10 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCaisa is now at home and his son has a s

2014-10-15 22:15:41 703

原创 codeforces Round #264(div2) D解题报告

D. Gargari and Permutationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGargari got bored to play with

2014-10-15 22:14:04 606

原创 codeforces Round #264(div2) C解题报告

C. Gargari and Bishopstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGargari is jealous that his friend C

2014-10-15 22:08:37 658

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除