
想法技巧
文章平均质量分 83
码代码的猿猿的AC之路
人一我百,人十我万追逐青春的梦想,怀着自信的心,永不放弃
展开
-
HDOJ 4277 USACO ORZ 搜索+剪枝
暴力搜索+轻微剪枝 固定第一个数的话可以减少2/3的时间…..USACO ORZTime Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4018 Accepted Submission(s): 1340Problem Descriptio原创 2015-09-07 22:40:40 · 786 阅读 · 0 评论 -
Codeforces 487D. Conveyor Belts 分块+DP
题意:有一个n×m的地图,上面有三种符号 分别表示向上,向左,向右有两种操作,A X Y询问从一个点(X,Y)开始最终会走到哪个点或者死循环 , C X Y ch 表示将地图上(X,Y)的符号换成ch考虑到没有向下的操作,那么陷入死循环的情况只有一种可能即'>' '用分块操作,分成sqrt(n)块,用DP预处理每一块中的点可以到哪个点,-1表示这个点死循环对于操作A,如原创 2015-03-17 19:34:48 · 1301 阅读 · 0 评论 -
Codefources 519D. A and B and Interesting Substrings
D. A and B and Interesting Substringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA and B are preparing原创 2015-03-05 16:44:42 · 1031 阅读 · 0 评论 -
Codeforces 520C. DNA Alignment 找规律
等价于一个不左移一个左移然后结果乘上n,也就是第二个串的每个字符都会和第一个串的某个字符配对一次,所以选择出现次数最多的字符更好.如果有多个字符出现次数都是最多的,结果为最多的字符种类数的n次方C. DNA Alignmenttime limit per test2 secondsmemory limit per test256原创 2015-03-02 23:30:45 · 2118 阅读 · 0 评论 -
HDOJ 5143 NPY and arithmetic progression DFS
DFS.....多余3个的数可以自己成等比数列和其他数组合成等比数列的有1,2,3, 2,3,4 1,2,3,4 三种情况NPY and arithmetic progressionTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm原创 2014-12-13 23:33:20 · 1450 阅读 · 0 评论 -
HDOJ 5141 LIS again 二分
二分求LIS对每一个位置为终点的LIS记录开头的最靠右边的值....LIS againTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 272 Accepted Submission(s): 96原创 2014-12-11 16:06:44 · 970 阅读 · 0 评论 -
Uva 11971 Polygon 想法
多边形的组成条件是最长边不能占边长总和的一半,将木棒想象成圆多砍一刀,然后是简单概率.PolygonTime Limit: 1000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescription原创 2015-01-30 21:53:59 · 1651 阅读 · 0 评论 -
BZOJ 2038: [2009国家集训队]小Z的袜子(hose) 分块
分块大法好2038: [2009国家集训队]小Z的袜子(hose)Time Limit: 20 Sec Memory Limit: 259 MBSubmit: 2938 Solved: 1303[Submit][Status]Description作为一个生活散漫的人,小Z每天早上都要耗费很久从一堆五颜六色的袜子中找出一双来穿。终于有一天,小Z再也无法忍受这原创 2014-12-23 01:01:48 · 1624 阅读 · 0 评论 -
HDOJ 5100 Chessboard 构造
MATRIX67大神: http://www.matrix67.com/blog/archives/5900ChessboardTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 538 Accepte原创 2014-12-05 00:06:34 · 5096 阅读 · 0 评论 -
Codeforce 383C. Propagating tree
C. Propagating treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIahub likes trees very much. Recently h原创 2014-11-26 11:55:50 · 1247 阅读 · 0 评论 -
HDOJ 5098 Smart Software Installer 拓扑排序
拓扑排序:两个队列,一个放不需要重启入度为0的,一个放需要重启入度为0的....从不需要重启的队列开始,每弹出一个数就更新下入度,遇到入读为0的就加入到相应队列里,当队列空时,记录重启次数+1,交换队列..一直到两个队列都为空Smart Software InstallerTime Limit: 2000/1000 MS (Java/Others) Memory原创 2014-11-04 10:42:31 · 1238 阅读 · 0 评论 -
HDOJ 5063 Operation the Sequence
注意到查询次数不超过50次,那么可以从查询位置逆回去操作,就可以发现它在最初序列的位置,再逆回去即可求得当前查询的值,对于一组数据复杂度约为O(50*n)。Operation the SequenceTime Limit: 3000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot原创 2014-10-17 10:54:10 · 936 阅读 · 0 评论 -
ZOJ 3829 Known Notation 乱搞
乱搞:1.数字的个数要比*的个数多一个,如果数字不足需要先把数字补满2.最优的结构应该是数字都在左边,*都在右边3.从左往右扫一遍,遇到数字+1,遇到*-1,如果当前值Known NotationTime Limit: 2 Seconds Memory Limit: 65536 KBDo you know reverse Polish no原创 2014-10-15 09:16:32 · 963 阅读 · 0 评论 -
Codeforces 474 E. Pillars
水过......E. Pillarstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMarmot found a row with n原创 2014-10-09 20:46:08 · 1384 阅读 · 0 评论 -
Codeforce 475 C. Kamal-ol-molk's Painting
从最左上的点开始枚举长宽....C. Kamal-ol-molk's Paintingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output原创 2014-10-09 10:51:52 · 1503 阅读 · 0 评论 -
Codeforces 484E. Sign on Fence 可持久化线段树
大概题意:给一数组a,问在某一区间L~R中,问对于连续的长为W的一段中最小的数字的最大值是多少.显然可以转化成二分高度然后判断可行性的问题.考虑到高度肯定为数组中的某一个值,将数组从大到小排序. 建n棵线段树,对于第 i 棵线段树,将 大于等于a[i] 的叶子的值设置为1,其他的叶子设置为0,问题就转化成了用线段树求某一区间中最长的连续的1的个数,这是一个线段树原创 2015-03-11 23:11:10 · 1450 阅读 · 0 评论 -
Codeforces 487C. Prefix Product Sequence 逆元+构造
题意:对于数字n, 问是否存在1~n的一个排列 使这个排列的每一个前缀的乘积模上n 可以是0~n-1的一个排列解析:通过观察1肯定要在首位,n一定要在最后构造 a[i]=i*inv[i-1] , 这样用逆元把前面每个数的影响都消除掉C. Prefix Product Sequencetime limit per test1 s原创 2015-03-12 20:38:28 · 959 阅读 · 0 评论 -
HDOJ5355 Cake 构造
直接贪心的做法是不对的(例如: 23 6 , 27 7 , 28 7, 31 8 等...)多校的时候因为SPJ的问题很多WA的程序都过了,实际上这题并没有那么水......无解的有两种情况 1: sum不能被m整除 2: sum/m比n小剩下的情况都有解:标程的做法是根据: n(n+1)/(2*m) 每一组里都有k对组合,如第一行中的(11 100) (12 99) (13 98)....因为有m行所以这样的组合有2*k*m个,这些对都可以凑成一样的大小剩下的为粉红色的部分, 这些数字有(n原创 2015-08-07 16:40:28 · 584 阅读 · 0 评论 -
HDOJ 5351 MZL's Border 找规律
打出前i个串的kmp的fail指针:p: ab0 0 0 p: aba0 0 0 1 p: abaab0 0 0 1 1 2 p: abaababa0 0 0 1 1 2 3 2 3 p: abaababaabaab0 0 0 1 1 2 3 2 3 4 5 6 4 5 p: abaababaabaababaababa0 0 0 1 1 2 3 2 3 4 5 6 4 5原创 2015-08-05 16:12:40 · 546 阅读 · 0 评论 -
HDOJ 5348 MZL's endless loop 乱搞
对每个点DFS,根据入度和出度的情况选择标记入边或者出边进行DFSMZL's endless loopTime Limit: 3000/1500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1037 Accepted Submission(s原创 2015-08-05 11:51:02 · 728 阅读 · 0 评论 -
HDOJ 5308 I Wanna Become A 24-Point Master 构造
构造题,前面十几个手工处理....n很大时有很多构造方法,一阵乱搞就可以了......I Wanna Become A 24-Point MasterTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 128原创 2015-07-23 19:05:09 · 1099 阅读 · 0 评论 -
HDOJ 5385 The path 构造
The pathTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 521 Accepted Submission(s): 190Special JudgeProblem DescriptionYou ha原创 2015-08-15 13:27:43 · 886 阅读 · 0 评论 -
HDOJ 5534 Virtual Participation 构造
构造小于10^5的直接输出1大于10^5的构造如下的串1111...12222...233....3.....t,t+1,t+2..设长度为n,每种字符出现了L[i]次则不同的串有 n*n+n-sigma(L[i])=2*K大约估计一个n,用贪心求出LVirtual ParticipationTime Limit: 2000/1000 MS (Java原创 2015-08-03 14:20:25 · 669 阅读 · 0 评论 -
HDOJ 5292 Pocket Cube 构造
.......Multi-University Training Contest 1 题解 BY FZU">Pocket CubeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 6 Accepted Sub原创 2015-07-21 19:25:31 · 1448 阅读 · 0 评论 -
BZOJ 1176: [Balkan2007]Mokia CDQ分治
第一道CDQ分治....以下来自 陈丹琦 的 从《Cash》谈一类分治算法的应用:算法分析这个问题是IOI 2000 Mobile的加强版:Mobile中W≤1000,就可以利用二树状数组在O(log22n)的时间复杂度内维护出操作1)和操作2).这个问题中W很大,开二维树状数组O(W2)的空间显然吃不消,考虑使用动态空间的线段树,最多可能达到操作次数 * (log2W)原创 2015-07-31 15:56:10 · 921 阅读 · 0 评论 -
HDOJ 5302 Connect the Graph 构造
如果1度的点不是偶数,则无解构造一个环,这样所有的点都可以有俩个度.其他所有情况都可以通过删掉一些边来得到,而且黑边和白边是互相独立的....考虑到不能有重边,则至少得有2*n条边,所以n==4的情况(1 2 1)需要特判Connect the GraphTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/原创 2015-07-28 09:59:24 · 781 阅读 · 0 评论 -
Codeforces 550D. Regular Bridge 构造
求一个图,每个点的度数都为K而且必须至少要有一个桥.构造题:只有k为奇数的时候有解, 构造这样的一个图,左边一团有 k+1 个点 , 右边一团也有 k+1 个点, 中间经过 m1 , m2 连着一个桥.如果左右两团是完全图,则每个点的度数都为k, 现在考虑如何通过m1,m2连接起来而又不改变度数.显然这个图是对称的,只考虑左边和点m1,m1和m2是一个桥,要连一条边原创 2015-06-07 21:11:12 · 931 阅读 · 0 评论 -
BZOJ 1011: [HNOI2008]遥远的行星
n大于一定的范围后,取近似值1011: [HNOI2008]遥远的行星Time Limit: 10 Sec Memory Limit: 162 MBSec Special JudgeSubmit: 2350 Solved: 837[Submit][Status][Discuss]Description直线上N颗行星,X=i处有行星i,行星J受到行星I的作用原创 2015-05-10 17:16:28 · 1184 阅读 · 1 评论 -
Codeforces 509D. Restoring Numbers 构造+数学
D. Restoring Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya had two arrays consisting of non-原创 2015-04-02 20:48:18 · 1037 阅读 · 0 评论 -
Codeforces 500E. New Year Domino 倍增/线段树+离线
E. New Year Dominotime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCelebrating the new year, many people po原创 2015-03-23 22:37:39 · 1715 阅读 · 0 评论 -
Codeforces 490E. Restoring Increasing Sequence 二分
统计有几个'?',然后二分检测取满足条件的最小的数就可以了. 注意没有问号的时候也要检测一下....原创 2015-03-14 12:56:38 · 1197 阅读 · 0 评论 -
Codeforces 474 F. Ant colony
线段树求某一段的GCD.....F. Ant colonytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMole is hungry again原创 2014-10-09 16:23:04 · 1496 阅读 · 0 评论 -
Codeforces 475 D. CGCDSSQ
暴力+维护某个数到前面一个能产生不同GCD的数的位置.......D. CGCDSSQtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output原创 2014-10-08 15:09:00 · 1873 阅读 · 0 评论 -
Codeforces 464 C. Substitutes in Number
从后往前推,记录每个数字代表的值和他的倍数....C. Substitutes in Numbertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output原创 2014-09-10 17:47:50 · 1501 阅读 · 0 评论 -
Codeforces 464 A. No to Palindromes!
因为初始的串是不包含回文的,所以只要判断最后一个字符和前一个和前前一个不要构成回文就可以了,从最后一位开始加1枚举,如果不可以就往前枚举一位,一直到可以把当前的字符确定下来为止,再往后面构造尽量小的不构成回文的串就可以了.A. No to Palindromes!time limit per test1 secondmemory limit per原创 2014-09-09 11:33:38 · 1393 阅读 · 0 评论 -
SWERC13 Decoding the Hallway
找规律 S+1 = S +'L'+~rev(S)Problem DDecoding the HallwayProblem DEdward is now 21 years old. He has to appear in an exam to renew his State Alchemisttitle. This year the exam is arranged原创 2014-08-25 01:24:02 · 1372 阅读 · 0 评论 -
Codeforces 292D. Connected Components
并查集预处理+暴力D. Connected Componentstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe already原创 2014-09-08 17:00:37 · 1232 阅读 · 0 评论 -
Codeforces 460 D. Little Victor and Set
暴力+构造If r - l ≤ 4 we can all subsets of size not greater than k. Else, if k = 1, obviously that answer is l. If k = 2, answer is 1, because xor of numbers 2x and 2x + 1 equls 1. If k ≥原创 2014-08-24 11:20:21 · 1179 阅读 · 0 评论 -
HDOJ 4430 Yukari's Birthday
C++高精度问题太蛋疼了....Yukari's BirthdayTime Limit: 12000/6000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2891 Accepted Submission(s): 604Problem D原创 2014-09-06 23:19:19 · 955 阅读 · 0 评论 -
HDOJ 4972 A simple dynamic programming problem
找规律。。。数据可能不合法。。。输出0A simple dynamic programming problemTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 85 Accepted Submission(s): 3原创 2014-08-21 18:44:58 · 1159 阅读 · 0 评论