#6

by asd

Submitted 4 years 10 months 1 day ago
Sat Jan 11 17:27:26 CST 2020
Judger: YourFa
Dataset Version: v0

0 ms / 0 KB
Init 0
Problem: testProblemSet.realOI
Language: GNU C++ 11


#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;


const int INF=1000000007;
const int maxn=200005;


int c[maxn];
int ans[maxn];
int n,p;

int main(){
	//freopen("bomb.in","r",stdin);
//	freopen("bomb.out","w",stdout);
	scanf("%d%d",&n,&p);
	while(p--){
		int s,m,d,i,a;
		scanf("%d%d%d%d%d",&s,&m,&d,&i,&a);
		if(d==1){
			int e=s+m-1;
			if(e>n)e=n;
			c[s]+=i;
			c[s+1]-=i;
			c[s+1]+=a;
			c[e+1]-=a;
			c[e+1]-=i+(e-s)*a;
			c[e+2]+=i+(e-s)*a;
		}
		else{
			int e=s-m+1;
			if(e<=0)e=1;
			swap(e,s);
			i=i+(e-s)*a;
			a=-a;
			c[s]+=i;
			c[s+1]-=i;
			c[s+1]+=a;
			c[e+1]-=a;
			c[e+1]-=i+(e-s)*a;
			c[e+2]+=i+(e-s)*a;
		}
		//ans[0]=0;
		//for(int i=1;i<=n;++i){
		//	ans[i]=ans[i-1]+c[i];
		//}
		//for(int i=1;i<=n;++i){cerr<<c[i]<<' ';}
		//cerr<<endl;
		//for(int i=1;i<=n;++i){cerr<<ans[i]<<' ';}
		//cerr<<endl;
	}
	ans[0]=0;
	for(int i=1;i<=n;++i){
		ans[i]=ans[i-1]+c[i];
	}
//	for(int i=1;i<=n;++i){cerr<<ans[i]<<' ';}
//	cerr<<endl;
	int g=0;
	for(int i=1;i<=n;++i){
		g+=ans[i];
		printf("%d ",g);
	}
	return 0;
}