比赛 |
ZLXOI2015Day1 |
评测结果 |
AAAAAAAAAA |
题目名称 |
虐狗大赛 |
最终得分 |
100 |
用户昵称 |
zero_std |
运行时间 |
0.482 s |
代码语言 |
C++ |
内存使用 |
2.83 MiB |
提交时间 |
2015-10-29 10:03:01 |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <stack>
#include <algorithm>
#include <string>
#include <vector>
#include <ctime>
#include <bitset>
#define INF 0x3f3f3f3f
#define MAXN 110000
#define lowbit(x) (x)&(-(x))
#define CLR(a,b) memset((a),(b),sizeof((a)))
using namespace std;
struct Edge {
int u, v, w;
};
template <class T> inline T min(T& a, T& b) {
return a > b ? b : a;
}
template <class T> inline T max(T& a, T& b) {
return a < b ? b : a;
}
template <class T> inline T abs(T& a) {
return a > 0 ? a : -a;
}
int N, Q;
int H[110000], D[110000];
struct tree_array{
struct tree_array_single{
int arr[MAXN];
void add(int x,int n){while(x<=N)*(arr+x)+=n,x+=lowbit(x);}
int sum(int x){int sum=0;while(x)sum+=*(arr+x),x-=lowbit(x);return sum;}
}T1,T2;
void reset(){CLR(T1.arr,0); CLR(T2.arr,0);}
void add(int x,int n){T1.add(x,n);T2.add(x,x*n);}
void update(int L,int R,int n){add(L,n);add(R+1,-n);}
int sum(int x){return (x+1)*T1.sum(x)-T2.sum(x);}
int query(int L,int R){return sum(R)-sum(L-1);}
};
tree_array s1, s2;
inline void in() {
int i;
scanf("%d",&N);
for(i = 1;i <= N;i ++) scanf("%d", &*(H+i)), s1.update(i, i, *(H+i)), s2.update(i, i, 0);
for(i = 1;i <= N;i ++) scanf("%d", &*(D+i));
scanf("%d", &Q);
}
inline void solve() {
int i, j, ope, a, b, c;
for(i = 0;i < Q;i ++) {
scanf("%d", &ope);
if(!ope) {
scanf("%d%d%d", &a, &b, &c);
s1.update(a, b, -c);
s2.update(a, b, 1);
}
if(ope) {
for(j = 1;j <= N;j ++) {
int t1 = s1.query(j, j);
int t2 = s2.query(j, j);
printf("%d ", t1 + t2 * *(D + j));
}
printf("\n");
}
}
}
int main() {
freopen("thebigmatch.in", "r", stdin);
freopen("thebigmatch.out", "w", stdout);
in();
solve();
return 0;
}