- 博客(69)
- 资源 (1)
- 收藏
- 关注
原创 codeforces Round #Pi (div.2) 567ABCD
567A Lineland Mail题意:一些城市在一个x轴上,他们之间很喜欢写信交流,送信的费用就是两个城市之间的距离,问每一个城市写一封信给其他城市所花费的最小费用和最大的费用。没什么好说的,直接做。特判最左边的和最右边的。其他的最小值在相邻的城市取,最大的在两边的城市与本城市取最大值。代码:#include #include #include #include
2015-08-08 15:10:01
781
原创 poj3468 线段树区间求和
用Lazy标记,延迟更新,标记如果不开long long 就会WA 我计算了一下,10W*10W是超int #include #include #include #include #include #include #include #include #include #include #include #include #defi
2015-08-04 16:39:19
369
原创 hdu5316 线段树
题意有点难懂找一个区间中奇偶交替的子序列的最大值 奇偶交替可以是以奇数开头奇数结尾奇数开头偶数结尾偶数开头偶数结尾偶数开头奇数结尾四种情况还有就是单点更新 维护线段树 #include #include #include #include #include #include #include #include #include
2015-08-04 16:38:15
485
原创 poj3667 线段树
第二次做这种维护连续的区间问题经典的维护连续的区间 跟poj2892类似但是本篇的代码风格写的比上次要好些题意:一开始一个酒店有n间空房有两种操作 1 需要x间连续的房间要入住,输出连续的x间房的最左边的房号 2 从第x间房之后的y间房清空。方法:入住的时候查询线段树所维护的连续区间找到最左的一个标号,输出然后更新线段树退房的时候更新线段树,清空。 #in
2015-08-04 16:36:58
392
原创 poj3264 线段树维护最大值最小值
用线段树来维护区间的最大值最小值 建好线段树,就可以针对查询来查出最大值最小值 从而求出其差值 #include #include #include #include #include #include #include #include #include #include #include #include #include
2015-08-04 16:35:41
785
原创 poj2828 买票 线段树维护连续的区间
http://poj.org/problem?id=2828题意:有n个人来排队每一个来排队的人都站到自己想要站的位置上 在该位置以后的人 依次后退问最后的排队序列万万没有想到,本题是线段树。但它确实是。还是自己对线段树掌握的不够熟练从第n个人往第一个人看,每一个人的位置是代表着他站完之后前方还有多少空位。拿样例来看 40 77 1 511 332 6
2015-08-04 15:29:34
294
原创 hdu1166 敌兵布阵 线段树 单点更新
http://acm.hdu.edu.cn/showproblem.php?pid=1166入门级单点更新线段树,sum维护区间总的人数#include #include #include #include #include #include #include #include #include #include #include #include #inclu
2015-08-04 15:28:07
326
原创 hdu 1698 线段树 区间更新
http://acm.hdu.edu.cn/showproblem.php?pid=1698题意:在Dota游戏中,有一个名叫pudge的怪物。他有一条大铁钩子,又许多小铁钩子组成。Pudge有两种技能可以把从L到R区间的小钩子变成金钩或银钩子,来增加他钩子的价值L R num(1,2,3) 1是铁 2是银 3是金经过M次操作后,问大钩子的价值。做法:线段树区间更新,用s
2015-08-04 15:26:48
351
原创 hdu1754 单点更新
http://acm.hdu.edu.cn/showproblem.php?pid=1754中文题 不解释题意线段树 单点更新,维护区间的最大值#include #include #include #include #include #include #include #include #include #include #include #include #i
2015-08-04 15:25:16
308
原创 hdu1556 线段树更新区间
http://acm.hdu.edu.cn/showproblem.php?pid=1556中文题 不解释题意线段树典型区间更新问题,不能更新到叶子节点,需要延迟标记,否则TL#include #include #include #include #include #include #include #include #include #include #inclu
2015-08-04 15:24:17
327
原创 poj 2777 Count 线段树区间覆盖
http://poj.org/problem?id=2777跟贴报纸差不多,还不用离散化。本身木棍的颜色是0,也算一种颜色,给木棍涂颜色,颜色用数字代替是1~30,不过是随时询问,不像贴报纸就问一次。这个就要注意效率,用Lazy来延迟更新,登用到该值的时候再更新。两种操作C: L R color 从L到R区间长度的木棍全都涂上color(1~30)颜色,如果本来就有颜色
2015-08-04 15:23:00
441
原创 poj2892 同hdu1540 Tunnel Warfare 线段树
http://poj.org/problem?id=2892题意:在抗日时期,我方经常采用地道战,地雷战,麻雀战来袭扰日军。 现在n个村子一开始是全部联通的,假设成一条直线。 给出3种操作 D x x村庄的地道被日本鬼子炸毁 (炸毁之后地道无法相连) Q x 问有与x相连的村庄最长的长度 假设一个村为一个长度单位 R 修复日本鬼子最近一个炸毁的村庄
2015-08-04 15:20:21
352
原创 poj 2528 Mayor's posters 线段数+离散化
http://poj.org/problem?id=2528题意: 给n个广告纸,先给的先按位置贴在墙上 后给的可以覆盖前面的广告问,最后能看到多少广告纸,看不全也算看到由于广告纸的长度范围太大,1~1千万 纯线段树 TL + ML 但是 注意到广告纸最多有十万。这样我们就可以离散化,把一个大的区间离散到一个小的区间里面例如: n = 3 区间为 1 10,
2015-08-04 15:16:44
328
原创 hdu1394 Minimum Inversion Number 线段树
http://acm.hdu.edu.cn/showproblem.php?pid=1394把n个数一次存入线段数 在每个数data[i]存进去之前 查找大于data[i]的数量 从而在所有的数加完之后 就可以算出该序列的逆序数而在本题中还有一个技巧,在该序列第一位置的数移动到最后 就可以推出来我们假设 数字是从1开始的 这样比较直观第一个数对该序列答案的影响就是
2015-08-04 15:13:32
289
原创 poj 2452 Sticks Problem
http://poj.org/problem?id=2452#include #include #include #include #include #include #include #include #include #include #include #include #include #define mem(a) memset(a,0,sizeof(a))
2015-07-27 17:37:25
426
原创 poj3250 Bad Hair Day
http://poj.org/problem?id=3250单调栈#include #include #include #include #include #include #include #include #include #include #include #include #define mem(a) memset(a,0,sizeof(a));#de
2015-07-27 17:35:39
687
原创 poj2559 Largest Rectangle in a Histogram
http://poj.org/problem?id=2559题意非常简单,以每个楼为最低的楼,往两边拓展,直到找到比该楼还低的楼为止,最后求最大的面积(该楼的高度*拓展的宽度)。用单调递减队列来维护区间的最小值。每一次出队列 就说明有一个楼比当前队尾的楼要低,就要出队列,出队列的同时记录一下位置左右各走一遍即可。#include #include #include #
2015-07-27 17:27:56
572
原创 hdu 5294 Tricks Device 最短路+最大流
Tricks DeviceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Problem DescriptionInnocent Wu follows Dumb Zhang into a ancient tomb. Innocent Wu’s at th
2015-07-22 19:24:04
800
原创 最大网络流算法
最大网络流算法之增广路算法理论讲解为了在一个图中得到最大流,可以从任何一个可行流开始,沿着增广路对网络流进行增广,知道图中不存在增广路为止。如何找增广路:从源点S出发用求最短路的算法根据边的容量 - 流量 找一条最短路 记录下来该路径,走一边该路径,找到该路中(容量-流量的最小值),对该路径上所有边的流量都加上该最小值。直到找不到图中的增广路,即说明该网路的流量已经达到了最大。
2015-07-16 18:29:00
719
原创 Java 课堂笔记(5)
继承 多态类的继承/* * 在存在继承时, * 1 属性和方法都会被继承到子类中 * 2 静态的类变量方法,回被共享到子类 共享 就是 你没有 可以让你用 * 3 子类的构造方法被在调用时 会在一行调用 父类的无参构造方法 * 4 Java 不支持多重继承,一个类只能有一个父亲,但可以有多个子类 *///子类继承父类,会继承父类中 所有的属性
2015-01-15 14:14:58
620
原创 Java 课堂随笔 (4)
构造方法 非常极其特别的重要。new 方法开辟出堆中空间后,被调用来初始化对象。 与普通方法不一样。 初始化类中属性的。 1 在命名上构造方法的方法名。必须与类名相同,完全一致。 2 构造方法无返回值类型。 public Hello 面向对象的特点: 继承 封装 多态 抽象 如过就三个,就把抽象去掉;
2015-01-15 08:14:39
719
原创 Java课堂笔记(3)
面向对象 纯面向对象 我们用程序来表述的问题,都是与面向对象。例:锅 (模子,特点) 属性(圆,锅把,平) 用途( 炒菜烧水) 马 (长脖子,长腿,长尾巴)(
2015-01-14 09:56:35
694
原创 Java 课堂随笔(2)
循环 for( 声明; 循环条件 ; 循环变量的变化 ) { }有时这三个都不必填写 while(1)--死循环 在循环里 可用break 来跳出当前循环 ;continue 结束本次循环,继续下一次; return 结束当前方法 do..while()
2015-01-13 08:15:45
713
2
原创 Java 课堂随笔(1)
Java 今天 实训Java 上课讲得 记录下来用eclipse建项目 src ---放代码的地方 系统类库 在src里件建package 命名在package里建class—new java class piublic 打钩 一个JAva中 可以有多个类 但是 只有一个被修饰,这个java文件的文件名必须和Public类的类名完全一致
2015-01-12 10:52:06
577
转载 aim
http://www.cnblogs.com/wanghetao/archive/2011/12/14/2288125.html 转自ACM的常用算法(西交POJ)ACM常用算法及练习第一阶段:练经典常用算法,下面的每个算法给我打上十到二十遍,同时自己精简代码,因为太常用,所以要练到写时不用想,10-15分钟内打完,甚至关掉显示器都可以把程序打出来. 1.最短路(Floy
2014-12-09 09:09:15
818
原创 hdu5124 lines (输入输出挂写的)
linesTime Limit: 5000/2500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem DescriptionJohn has several lines. The lines are covered on the X axs. Let A is a point which is
2014-11-30 14:05:25
784
原创 poj1019 Number Sequence
大致题意:有一串数字串,其规律为1 12 123 1234 12345 123456 1234567 12345678 123456789 12345678910 1234567891011 123456789101112······k输入位置n,计算这一串数字第n位是什么数字,注意是数字,不是数!例如12345678910的第10位是1,而不是10,第11位是0,也不是1
2014-11-09 11:39:14
552
1
转载 漫漫ACM之路
时间复杂度(渐近时间复杂度的严格定义,NP问题,时间复杂度的分析方法,主定理)排序算法(平方排序算法的应用,Shell排序,快速排序,归并排序,时间复杂度下界,三种线性时间排序,外部排序)数论(整除,集合论,关系,素数,进位制,辗转相除,扩展的辗转相除,同余运算,解线性同余方程,中国剩余定理)指针(链表,搜索判重,邻接表,开散列,二叉树的表示,多叉树的表示)按位运算(and,or,
2014-10-26 18:18:48
756
原创 Black Box (优先队列)
Black BoxTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7614 Accepted: 3128DescriptionOur Black Box represents a primitive database. It can save an int
2014-10-10 11:54:35
676
原创 poj 3253
题目链接#include #include #include #include #include #include #include #include #include #define N 100#define mem(a) memset(a,0,sizeof(a));using namespace std;struct cmp1{ bool operat
2014-10-09 21:28:50
653
原创 poj 1035 Spell checker
Spell checkerTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 19306 Accepted: 7056DescriptionYou, as a member of a development team for a new spell check
2014-10-02 15:35:03
472
原创 poj 2488 A Knight's Journey (Dfs)
A Knight's JourneyTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 30579 Accepted: 10476DescriptionBackgroundThe knight is getting bored of seeing the sa
2014-08-09 11:07:09
640
原创 POJ 3087 Shuffle'm Up (模拟)
Shuffle'm UpTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5790 Accepted: 2715DescriptionA common pastime for poker players at a poker table is to shuf
2014-08-09 11:04:14
704
原创 poj 1426 Find The Multiple(bfs)
Find The MultipleTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 18023 Accepted: 7303 Special JudgeDescriptionGiven a positive integer n, write a prog
2014-08-09 10:58:46
708
原创 zoj 2876 Phone List(tire 树)
Phone ListTime Limit: 5 Seconds Memory Limit: 32768 KB Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let's say the p
2014-08-09 10:56:27
742
原创 poj 2503 Babelfish(trie树)
BabelfishTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 32439 Accepted: 13954DescriptionYou have just moved from Waterloo to a big city. The people here
2014-08-09 10:53:59
842
原创 poj 1113 wall (凸包)
WallTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 29462 Accepted: 9855DescriptionOnce upon a time there was a greedy King who ordered his chief Architec
2014-08-03 21:09:53
664
原创 poj 2251 Dungeon Master()
poj 2251Dungeon MasterTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 16485 Accepted: 6408DescriptionYou are trapped in a 3D dungeon and need to find the quickest w
2014-08-03 21:03:10
810
原创 POJ 2318 TOYS (叉积)
TOYSTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 10258 Accepted: 4916DescriptionCalculate the number of toys that land in each bin of a partitioned toy
2014-08-02 10:08:23
738
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人