hdu1540】的更多相关文章

title: hdu-1540线段树刷题 date: 2018-10-18 19:55:21 tags: acm 刷题 categories: ACM-线段树 概述 哇,,,这道线段树的题可以说是到目前为止我所做过的最难的一道了吧QAQ,,,,,, 一开始读完题就是一脸懵逼,,,,完全不知道该从哪里下手,,,就是知道这是一道线段树的题也不知道该怎么下手啊啊啊,,,, 最后还是看了kaungbin大佬的代码,,,QAQ 光是读代码就花了一两个小时,,,(不过也有可能和今天贼困有关,,,脑袋不怎么转…
题目链接:https://vjudge.net/problem/HDU-1540 uring the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay in a line. Except the two at…
HDU1540 线段树最大连续区间. 给定长度为n的数组,m次操作. 操作D,删除给定节点. 操作R,恢复最后一个删除的节点. 操作Q,询问给定节点的最大连续区间 维护三个值,区间的最大左连续区间,最大右连续区间,最大连续区间 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <sta…
Tunnel Warfare Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7703    Accepted Submission(s): 2981 Problem Description During the War of Resistance Against Japan, tunnel warfare was carried out…
分析:不需要线段树,set可过,STL大法好 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <set> #include <stack> using namespace std; ; set<int>s; bool d[N]; stack<int>p; ]; int main() {…
Tunnel Warfare Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3318    Accepted Submission(s): 1280 Problem Description During the War of Resistance Against Japan, tunnel warfare was carried ou…
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1540 题意:是一条线上的点,D x是破坏这个点,Q x是表示查询以x所在的最长的连续的点的个数,R是恢复上一次破坏的点. 线段树功能:单点修改,区间求值. 分析: pre数组记录区间左端点开始的最大连续个数,  suf数组记录区间右端点开始往左的最大的连续个数,sum数组表示该区间最大的连续点的个数. sum[rt]最大值是左区间的最大值或右区间的最大值或左区间的suf+右区间的pre. #prag…
https://vjudge.net/contest/66989#problem/I #include<iostream> #include<cstdio> #include<cmath> #include<stack> #include<cstring> #include<algorithm> using namespace std; #define LL long long #define ls l,m,rt<<1 #…
During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay in a line. Except the two at the ends, every village was directly con…
题目链接:1540 Tunnel Warfare 以为单组输入 这个题多组输入 结构体记录每个区间左边和右边的连续区间 ms记录最大 在查询操作时: 1.这个点即将查询到右区间 看这个点 x 是否存在于右区间的ls 如果存在说明有可能 左区间的rs 和右区间的 ls 是连续的 这时候我们要考虑查询两个区间并且 值想加 查询 左区间的时候同理 #include<bits/stdc++.h> using namespace std; #define maxn 500010 struct ac{ i…
询问操作需要搞一下 今天被区间合并降智了 /* D a: 摧毁第a个点 Q a:询问a所在的点的块大小 R :修复最后被破坏的点 对于所有的点需要进行一次更新 更新比较容易,tag用来表示区间是否是完整的 查询时如果pos所在的大块有tag标记,那么直接返回块的大小即可 反之,如果pos在左区间,那就到左区间里去找: 如果pos的位置和rmx[rt<<1]相连,那么答案就是rmx[rt<<1]+lmx[rt<<1|1] 如果不相连,那么递归到左区间里找 如果pos在右区…
怎么会T啊 /* 三种操作:D x:第x个位置1 Q x:查询第x位置所在的0连续块 R :将上次D的位置置0 */ #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> using namespace std; #define maxn 50050 #define lson l,m,rt<<1 #define rson m+1,r,rt<<…
During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay in a line. Except the two at the ends, every village was directly con…
Tunnel Warfare Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3412    Accepted Submission(s): 1323 Problem Description During the War of Resistance Against Japan, tunnel warfare was carried ou…
During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay in a line. Except the two at the ends, every village was directly con…
Tunnel Warfare Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2396    Accepted Submission(s): 886 Problem Description During the War of Resistance Against Japan, tunnel warfare was carried out…
模板题>.<当初学了一波又忘了 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<iomanip> #include<cstdlib> #include<cstring> #include&…
Tunnel Warfare Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8115    Accepted Submission(s): 3142 Problem Description During the War of Resistance Against Japan, tunnel warfare was carried out…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1540 题目: 题意:总共有n个村庄,有q次操作,每次操作分为摧毁一座村庄,修复一座村庄,和查询与询问的村庄相连接的城市数量. 思路:线段树+区间合并. 代码实现如下: #include <set> #include <map> #include <queue> #include <stack> #include <cmath> #include &l…
During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay in a line. Except the two at the ends, every village was directly con…
---恢复内容开始--- Tunnel Warfare Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Genera…
题意:http://acm.hdu.edu.cn/showproblem.php?pid=1540 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #include <cstdio>//sprintf islower isupper #include <cstdlib>//malloc exit strcat itoa system("cls") #include <iostream>//p…
线段树保存每个区间的左边最大连续长度和右边最大连续长度~ #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<string> using namespace std; ; struct node { int l,r; int ll,rl,ml; //左边开始连续的最大长度和右边开始连续的最大长度 //以及这个区间的最大连续长度 }se…
http://acm.hdu.edu.cn/showproblem.php?pid=1540 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast…
转载自:http://blog.csdn.net/shiqi_614/article/details/8228102 之前做了些线段树相关的题目,开学一段时间后,想着把它整理下,完成了大牛NotOnlySuccess的博文“完全版线段树”里的大部分题目,其博文地址Here,然后也加入了自己做过的一些题目.整理时,更新了之前的代码风格,不过旧的代码仍然保留着. 同样分成四类,不好归到前四类的都分到了其他.树状数组能做,线段树都能做(如果是内存限制例外),所以也有些树状数组的题目,会标示出来,并且放…
hdu1540:http://acm.hdu.edu.cn/showproblem.php?pid=1540 题意:给你一列村庄,每个村庄给一个标号,1--n,然后毁掉一些村庄,或者重建几个村庄,重建是按照毁掉的反序建的,也就是说,最新建的是最后毁掉的那个村庄.在这些过程中会有一些查询,查询pos这个村庄所在的最长的连续村庄的个数.题解:很容易想到用线段树来维护,维护区间的最大左连续和最大右连续值,毁掉就是单点更新操作,同时把毁掉的村庄一次放入队列中,重建的时候只要从队列中取出即可.唯一难的是查…
原文出处:http://www.notonlysuccess.com/ (好像现在这个博客已经挂掉了,在网上找到的全部都是转载) 今天在清北学堂听课,听到了一些很令人吃惊的消息.至于这消息具体是啥,等我晚上再说23333 我大概的看了一下所讲内容及实例,果不愧是大牛级别的人,讲的很详细,所以决定转载过来. 对原文作者致以崇高的敬意. 以下是转载内容. [完全版]线段树 很早前写的那篇线段树专辑至今一直是本博客阅读点击量最大的一片文章,当时觉得挺自豪的,还去pku打广告,但是现在我自己都不太好意思…
LCIS Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6066    Accepted Submission(s): 2634 Problem Description Given n integers.You have two operations:U A B: replace the Ath number by B. (index…
线段树完全版  ~by NotOnlySuccess 很早前写的那篇线段树专辑至今一直是本博客阅读点击量最大的一片文章,当时觉得挺自豪的,还去pku打广告,但是现在我自己都不太好意思去看那篇文章了,觉得当时的代码风格实在是太丑了,很多线段树的初学者可能就是看着这篇文章来练习的,如果不小心被我培养出了这么糟糕的风格,实在是过意不去,正好过几天又要给集训队讲解线段树,所以决定把这些题目重新写一遍,顺便把近年我接触到的一些新题更新上去~;并且学习了splay等更高级的数据结构后对线段树的体会有更深了一…
https://cn.vjudge.net/problem/HDU-1540 题意 D代表破坏村庄,R代表修复最后被破坏的那个村庄,Q代表询问包括x在内的最大连续区间是多少. 分析 线段树的区间内,我们要用三个变量记录左边连续区间,右边连续区间和最大连续区间. 其它看代码,要比较仔细. #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include &l…