审稿打印问题# Immigration - 落地生根f*a2012-08-23 07:081 楼Give an array, operations on array are add(l,r,v), n operators, how to dothe operations in O(n)?
g*j2012-08-23 07:083 楼什么意思?举个例子?【在 f********a 的大作中提到】: Give an array, operations on array are add(l,r,v), n operators, how to do: the operations in O(n)?
f*a2012-08-23 07:085 楼array 1 2 3 4 5operation 0 1 2 ->it becomes 3 4 3 4 5operation 2 3 2 -> it becomes 3 4 5 6 5 ...【在 g***j 的大作中提到】: 什么意思?: 举个例子?
g*j2012-08-23 07:087 楼老大,我很愚笨,还是没有看明白什么意思。就不能说详细一点么?当然,你不想说我也不介意。【在 f********a 的大作中提到】: array 1 2 3 4 5: operation 0 1 2 ->it becomes 3 4 3 4 5: operation 2 3 2 -> it becomes 3 4 5 6 5 ...
c*02012-08-23 07:088 楼对区间[l,r]内的值都增加v,楼主为啥只要O(n)的时间复杂度【在 g***j 的大作中提到】: 老大,我很愚笨,还是没有看明白什么意思。就不能说详细一点么?当然,你不想说我: 也不介意。
p*22012-08-23 07:089 楼(defn f [l r v vec] (concat (take l vec) (map #(+ % v) (subvec vec l (inc r))) (nthrest vec (inc r))))
f*42012-08-23 07:0810 楼struct Interval { int l, r, v; };void solve(vector &a, const vector &adds) {vectorb(a.size()+1, 0);for (auto e:adds)b[e.l] += e.v, b[e.r+1] -= e.v;for (int i=0, prv=0; iprv += b[i];a[i] += prv;}}【在 f********a 的大作中提到】: Give an array, operations on array are add(l,r,v), n operators, how to do: the operations in O(n)?
a*e2012-08-23 07:0812 楼二爷威武,我还没看懂题目,您连解答都写出来了。 Orzr)【在 p*****2 的大作中提到】: (defn f [l r v vec] (concat (take l vec) (map #(+ % v) (subvec vec l (inc r): )) (nthrest vec (inc r))))