- 博客(45)
- 收藏
- 关注
原创 关于背包九讲01背包中的常数优化
关于背包九讲01背包中的常数优化for i ← 1 to N for v ← V to Ci优化为for i ← 1 to N for v ← V to max (V−key, Ci )其中key=∑niCi\sum_{i}^n Ci这里的max优化就是考虑了这样一种情况: 即使后面(i…n)的所有物品都被装入背包后,剩余的空间仍然比 Ci 大我们知道空间优化后的一维数组中的状态转
2017-02-08 16:06:47 4065 1
原创 关于传参的两种方式 传值与传址 的深入理解 (附 hdu3999
真的真的真的真的好久没码了………………最近因为要复习数据结构所以才兴起想要码一些跟考试相关的于是找了一下 BST 和 AVL 的题做做 结果一下搜就找到了 hdu3999解法很简单 只要建立一个 BST 再对其先序遍历即可然而…………问题出在这个代码上int main(){ int tmp; while(scanf("%d",&
2016-12-30 18:18:08 935
原创 算法学习—— tarjan算法求强连通分量 (附带 hdu1827
tarjan算法的第三个应用 求强连通分量强连通分量我就不具体介绍了这次的关键数组含义仍然没变 low[u] 仍然还是 u 能到达的最小的 low[v] ( low[v] 又由它最小的 low[v'] 决定 这里有个很关键的点 low[u] == dfn[u] 若以 求割点与桥的tarjan理解 表示 u 的子树的结点中最早能返回到 u,不能访问到u的祖先,
2016-11-18 23:55:57 395
原创 算法学习——求割点与桥的tarjan算法 HDU4738
前天打周赛做到 HDU4738 绞尽脑汁都没想到用什么好的方法来解决这个问题 周赛结束之后跟Yasola和xcy讨论了一下居然用到 tarjan算法 exm??? tarjan不是用来求 lca的么???回去怒补了一发才知道 tarjan原来是一系列是算法 根据我看到的博客原文 可以这么说 tarjan是个天才 他伟大的一生创造了无数的算法 统称 tarjan算
2016-11-15 11:48:58 2376 1
原创 医院设置wustOJ 二叉树中求*****
1007: 医院设置Time Limit: 1 Sec Memory Limit: 65535 MB 64bit IO Format: %lldSubmitted: 3 Accepted: 3[Submit][Status][Web Board]Description一颗二叉树有n(1≤n≤50)个结点,分别编号为1到n,每个结点代表一个居民点,每个居民点
2016-11-13 16:53:32 769
原创 哈夫曼编码 wustOJ
1010: 哈夫曼编码Time Limit: 1 Sec Memory Limit: 65535 MB 64bit IO Format: %lldSubmitted: 19 Accepted: 3[Submit][Status][Web Board]Description(1)首先构造哈夫曼树,原则是左孩子结点权值小于右孩子权值,如果结点权值有相等的,按照
2016-11-13 16:37:25 763
原创 HDU4403
A - A very hard Aoshu problemTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 4403DescriptionAoshu is very popular among p
2016-11-07 14:39:42 354
原创 iterator 的小东西
被C++的迭代器给坑了2个小时不得不立文警告自己C++的iterator 对于不同的STL来说 有不同的操作 小小的总结一下(1)所有迭代器p++ 后置自增迭代器++p 前置自增迭代器(2)输入迭代器*p
2016-10-13 16:06:47 288
原创 setjmp 与 longjmp
最近看到C看到一个很让人费解的函数组合 setjmp 和 longjmp 使用方法还是比较简单的setjmp设置跳跃点 longjmp表示跳跃具体的操作如下首先定义一个 唯一的标志性 flag jmp_buf变量再加上 函数申明 int setjmp(jmp_buf env); void longjmp(jmp_buf env, int val
2016-10-04 10:58:58 611
原创 关于大学学习的自我认知
我现在大二 感觉写这种东西有点晚了 感觉自己写这种东西有点不太符合自己的年纪了 有些人从高中甚至初中就已经察觉到了 而我现在才十分清晰地看到这个事实刚进大学的时候,第一堂课便是军训 军训还是那个样子 忍一下就好了 然而在中间的一段时间 拉歌的时候偶尔要求有人出场去才艺展示 我发现我什么都不会 军训中期有个中秋节晚会 我发现我
2016-09-22 13:20:12 1208
原创 HDU 5883 2016 ICPC青岛网络赛
The Best PathTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 784 Accepted Submission(s): 325Problem DescriptionAlice is planning
2016-09-21 20:49:04 325
原创 关于open操作的O_EXCL的存在应用价值理解
在我最近学习Linux C的过程中 总是看到这样的打开方式 open(const* pathname,O_CREAT|O_EXCL);O_CREAT 简单 就是想打开的文件如果不存在的话就会自动创建文件 而 O_EXCL 他的作用就是如果要创建一个文件 并且这个文件已经存在的话 会直接返回 并且 如果打开的文件是符号链接文件的话 也会直接返回
2016-09-19 22:37:00 1036
原创 hdu 1664 Different Digits 数位BFS(怎么都是这些题……
DescriptionGiven a positive integer n, your task is to find a positive integer m, which is a multiple of n, and that m contains the least number of different digits when represented in decimal. Fo
2016-08-26 14:39:44 521
原创 hdu 1226 超级密码 数位bfs(我称之为
Problem DescriptionIgnatius花了一个星期的时间终于找到了传说中的宝藏,宝藏被放在一个房间里,房间的门用密码锁起来了,在门旁边的墙上有一些关于密码的提示信息:密码是一个C进制的数,并且只能由给定的M个数字构成,同时密码是一个给定十进制整数N(0注意:由于宝藏的历史久远,当时的系统最多只能保存500位密码.因此如果得到的密码长度大于500也不能用来开启房门,这
2016-08-26 09:44:30 437
原创 hdu 1534 简单差分约束
DescriptionA project can be divided into several parts. Each part should be completed continuously. This means if a part should take 3 days, we should use a continuous 3 days do complete it. There
2016-08-24 16:55:30 370
原创 hdu 4474 数位BFS
DescriptionThere are tons of problems about integer multiples. Despite the fact that the topic is not original, the content is highly challenging. That’s why we call it “Yet Another Multiple Probl
2016-08-24 10:57:16 365
原创 hdu 1384 差分约束
DescriptionYou are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn.Write a program that: > reads the number of intervals, their endpoints and integers c1, ..., cn f
2016-08-22 20:51:41 377
原创 poj 1135 基础最短路
DescriptionDid you know that you can use domino bones for other things besides playing Dominoes? Take a number of dominoes and build a row by standing them on end with only a small distance in betwe
2016-08-22 14:30:51 383
原创 hdu2874 lca问题的Tarjan算法 内存险过
Problem DescriptionAfter World War X, a lot of cities have been seriously damaged, and we need to rebuild those cities. However, some materials needed can only be produced in certain places. So we n
2016-08-17 21:44:55 474
原创 算法学习————LCA问题的Tarjan算法
这里要介绍的 求最近公共祖先的算法是 Tarjan 算法 算法的核心思想在于 我们从一棵树的根节点开始向下深搜 当我们回溯的时候 我们才把两个集合合并 并更新根节点 这就意味着 对于一个节点 我们只有访问过他的所有子节点和他本身之后才更新他的根节点 我再简单点说 这样操作就实现了从叶子节点不断向上更新根节点
2016-08-17 11:11:41 262
原创 HDU 2818 && POJ1988 带权并查集
DescriptionJohn are playing with blocks. There are N blocks (1 M X Y : Put the whole pile containing block X up to the pile containing Y. If X and Y are in the same pile, just ignore this comman
2016-08-16 19:57:15 389
原创 HDU3047 Zjnu Stadium
DescriptionIn 12th Zhejiang College Students Games 2007, there was a new stadium built in Zhejiang Normal University. It was a modern stadium which could hold thousands of people. The audience Seats
2016-08-15 20:23:40 487
原创 HDU 2853 Assignment 建图的巧妙性
DescriptionLast year a terrible earthquake attacked Sichuan province. About 300,000 PLA soldiers attended the rescue, also ALPCs. Our mission is to solve difficulty problems to optimization the assi
2016-08-12 15:38:04 353
原创 算法学习———KM算法
KM算法 用于求二分图的最佳完美匹配 即权值最大的完美匹配 如果你也是个刚来学习KM算法的人 大概的用途肯定还是知道的吧 还是直接说重点吧 首先 理解KM算法前 必须有以下3个概念1.可行顶标 对于一个赋值二分图G(x,y,e,w) (x,y 代表二分图的两边顶点标号 e代表边 w代表边的权值 ) 我们对两边的每一个顶点
2016-08-11 10:22:39 3513 1
原创 hdu4634 状压bfs
Description“Swipe Bo” is a puzzle game that requires foresight and skill.The main character of this game is a square blue tofu called Bo. We can swipe up / down / left / right to move Bo up /
2016-08-10 15:13:03 367
原创 hdu1350 坐标建图后的最小路径覆盖
Taxi Cab SchemeTime Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1067 Accepted Submission(s): 533Problem DescriptionRunning a tax
2016-08-08 23:03:04 405
原创 hdu 1045 二分匹配练习 重在转化啊!!
Fire NetTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10212 Accepted Submission(s): 5975Problem DescriptionSuppose that we have
2016-08-08 19:42:05 235
原创 hdu1498 大水题
DescriptionOn Octorber 21st, HDU 50-year-celebration, 50-color balloons floating around the campus, it's so nice, isn't it? To celebrate this meaningful day, the ACM team of HDU hold some fuuny ga
2016-08-07 18:35:31 576 5
原创 hdu3275 线段树区间更新(略坑
先附上题目DescriptionFelicia was given a long string of fancy lanterns, but not all of them are on to light the night. Felicia felt bad about that and he wants to light up all the lanterns. The
2016-08-07 10:58:46 292
原创 hdu4499 超暴力dfs回溯
DescriptionIn Chinese Chess, there is one kind of powerful chessmen called Cannon. It can move horizontally or vertically along the chess grid. At each move, it can either simply move to another e
2016-08-03 09:38:59 423
原创 线段树之扫描线 自我小总结
扫描线扫描线 一开始看的时候真的是看的我整个人都不好了 全程懵逼状态 自信心严重受损 最后休整了一天再来看它 用纸和笔动手比划了一点时间才终于算是稍微明白了一点 所以我的建议还是大家自己动手比划一下 毕竟实践出真知 网上的那些题解虽然有图 但他们的语言也只有他们自己读得懂 自己动过手之后才知道他整个过程都是这么精妙据我
2016-08-02 08:34:51 450
原创 poj2777 第一道真正意义上完全自己做出来的线段树
DescriptionChosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem. There is a very long board with length
2016-07-29 15:16:24 1209
原创 POJ 3503 神特么的 BFS
再一次感慨英语是多么的重要 今天打比赛写到这题一直看不懂 尤其是最关键的那个双重否定一出来我整个人就懵逼了我还是弱弱的简单说一下题意吧 就是给你一个二维数组 每个值表示高度给你 长 宽 和一个数d如果一个点高度为h 只走 高度大于 h-d 的点并且达不到一个更高的点 那么这个点就是一个峰值求峰值的数目思路
2016-07-28 23:22:02 312
原创 hdu1198 不一样的搜索水题
Benny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are placed in these squares. Different square has a different type o
2016-07-27 20:25:17 419
原创 FZU2039 匈牙利算法
惯例来个简介 因为一开始看到这个算法的时候我也十分懵逼匈牙利算法是由匈牙利数学家Edmonds于1965年提出,因而得名。匈牙利算法是基于Hall定理中充分性证明的思想,它是部图匹配最常见的算法,该算法的核心就是寻找增广路径,它是一种用增广路径求二分图最大匹配的算法。其实说白了 这个算法用途有限 只能求二分图的最大匹配(如果没有任何扩展,毕竟我是鶸……
2016-07-26 21:45:22 310
原创 16年暑假集训 队服设计
昨晚队服顾问吧设计之后的队服拿出来让我们选择 果不其然 给的是整个T恤而不是jpg 图上还印着店家的logo很无语 就像开学那样的班服 就一件黑色衣服加一个大白 excuse me??? 是不是买同一件衣服就叫班服了??班服的事情我也懒得多说 形式性地给了班长面子买了下来穿了一天后就放着等着发霉了 因为班级人多 接触不大 对我来说 可有可
2016-07-26 08:30:46 350
原创 codeforces 14D 个人搜索小进阶
一看到这道题我就是大写 的懵逼这道题上半年去华科还是地大打邀请赛的时候做到过类似的题目,当初写不来就跳过去了,结果现在因果循环,真是造孽题意:给你一个无向不成环的图 让你找出两条不相交的树链 使其乘积最大思路 枚举每一条道路 并使其暂时断裂 再从这条道路的两端开始搜索 寻找最长的树链即可说实话 搜索的题目虽然说做的还凑合 但是这种
2016-07-24 15:24:01 303
原创 poj3494 Largest Submatrix of All 1’s
(以后题目都不贴了 流量上网 耗不起…………题意:给你一个矩阵 全由0,1组成 让你找出其中由1组成的面积最大的矩形题意非常简单 但让人无从下手其实如果我们一行一行处理 将矩阵转换到 柱状图 就有想法了eg 0 0 1 0 0 0 1 0 0 1 1 1 --> 0
2016-07-11 10:59:43 358
原创 poj2299 树状数组+离散化
DescriptionIn this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the s
2016-07-07 09:29:08 335
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人