很模板的题 在建树的时候输入 求和后更新 #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> #include<map> using namespace std; ///线段树 成段更新 struct node { int l; int r; int total; int mark; }; node a[100050*4]; int c[100050]…
一开始这条链子全都是1 #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> #include<map> using namespace std; ///线段树 区间更新 #define MAX 100050 struct node { int left; int right; int mark; int total; }; node tree[MAX*…
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 75541 Accepted: 23286 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of…
A Simple Problem with Integers Description 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 o…
Just a Hook Problem Description In the game of DotA, Pudge's meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length. Now Pudge wants to do some ope…
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 141093 Accepted: 43762 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type o…
Just a Hook Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 24474 Accepted Submission(s): 12194 Problem Description In the game of DotA, Pudge’s meat hook is actually the most horrible thing…
题目链接: http://poj.org/problem?id=3468 题意: 输入 n, m表初始有 n 个数, 接下来 m 行输入, Q x y 表示询问区间 [x, y]的和: C x y z 表示区间 [x, y] 内所有数加上 z : 思路: 线段树区间更新&区间求和模板: 代码: #include <iostream> #include <stdio.h> #define ll long long #define lson l, mid, rt <<…