A Simple Problem with Integers~POJ - 3468】的更多相关文章

A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 69589   Accepted: 21437 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of…
You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum of numbers in a given interval. Input The firs…
题目链接:https://cn.vjudge.net/problem/POJ-3468 题目大意:区间加减+区间查询操作. 具体思路:本来是一个线段树裸题,为了学习分块就按照分块的方法做吧. 分块真的好暴力,,,(但是还是挺优美的). 说一下各个数组的作用. a数组,代表每一个点的值. sum数组,代表分块后每一段的值. add数组,相当于线段树中的lazy标记,记录的数当前这一整段添加的值. l数组,r数组,记录每一段的左端点和右端点. belong数组,记录每一个数属于哪一个分块中. AC代…
题意:有一个比较长的区间可能是100000.长度, 每个点都有一个值(值还比较大),现在有一些操作,C abc, 把区间a-b内全部加上c, Qab,求区间ab的值. 分析:很明显我们不可能对区间的每个点都进行更新,不过我们可以使用一个op的开关,如果op等于0说明这个不需要更新,如果等于1就说明需要进行更新,这样只需要和插入的时候进行一下更新即可 *********************************************************************** 注意…
参考qsc大佬的视频 太强惹 先膜一下 视频在b站 直接搜线段树即可 #include<cstdio> using namespace std; ; int n,a[maxn]; struct Node{ int l,r; long long sum,lazy; void update(long long x){//用于更新区间和 和懒标记 sum+=1ll*(r-l+)*x; lazy+=x; } }tree[maxn*]; void push_up(int x){//用于用子区间重新计算该…
思路:线段树,区间更新,区间查找 #include<iostream> #include<vector> #include<string> #include<cmath> #include<set> #include<algorithm> #include<cstdio> #include<map> #include<cstring> #include<list> #define MAX…
//add,懒标记,给以当前节点为根的子树中的每一个点加上add(不包含根节点) // #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long long LL; ; int n, m; int w[N]; struct Node { int l, r; //总和 //如果只考虑当前节点及子节点…
C - A Simple Problem with Integers POJ - 3468   思路:线段树区间修改区间查询.又出现了 C++ WA    G++ AC的尴尬局面. #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define MAXN 100010 using namespace std; int n,m; struct nond{ int…
题目链接:http://poj.org/problem?id=3468 A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 144616   Accepted: 44933 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with…
POJ.3468 A Simple Problem with Integers(线段树 区间更新 区间查询) 题意分析 注意一下懒惰标记,数据部分和更新时的数字都要是long long ,别的没什么大坑. 代码总览 #include <cstdio> #include <cstring> #include <algorithm> #define nmax 200000 using namespace std; struct Tree{ int l,r; long lon…