比赛 Asm.Def战记之圣地亚哥“杯2015 评测结果 AAAAAAAWWW
题目名称 Asm.Def的命令 最终得分 70
用户昵称 欧鹰123 运行时间 0.553 s
代码语言 C++ 内存使用 106.62 MiB
提交时间 2019-10-23 18:12:28
显示代码纯文本
#include<bits/stdc++.h>

#define int long long

using namespace std;

int n,q;

struct node{
	int y,x,lazy,lazx;
}tree[2005000];

node a[2005000];

inline int read()
{
	int x=1,w=0;
	
	char ch=getchar();
	
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') x=-1;
	
	for(;ch>='0'&&ch<='9';ch=getchar()) w=w*10+ch-'0';
	
	return w*x;
}

void pushdown(int u,int l,int r)
{
	if(tree[u].lazx==0&&tree[u].lazy==0) return;
	//cout<<u<<'\n';
	tree[u*2].x+=tree[u].lazx;
	
	tree[u*2].y+=tree[u].lazy;
	
	tree[u*2+1].x+=tree[u].lazx;
	
	tree[u*2+1].y+=tree[u].lazy;
	
	tree[u*2].lazx+=tree[u].lazx;
	
	tree[u*2].lazy+=tree[u].lazy;
	
	tree[u*2+1].lazx+=tree[u].lazx;
	
	tree[u*2+1].lazy+=tree[u].lazy;
	
	tree[u].lazx=tree[u].lazy=0;
} 

void build(int u,int l,int r)
{
	if(l==r) 
	{
		tree[u].y=a[l].y;
		
		return;
	}
	
	int mid=(l+r)/2;
	
	build(u*2,l,mid);
	
	build(u*2+1,mid+1,r);
}

void update(int u,int l,int r,int x,int y,int dx,int dy)
{
	if(x<=l&&r<=y)
	{	
		tree[u].x+=dx;
		
		tree[u].y+=dy;
		
		tree[u].lazx+=dx;
		//cout<<u<<'\n';
		tree[u].lazy+=dy;
		
		return;
	}
	
	pushdown(u,l,r);
	
	int mid=(l+r)/2;
	
	if(x<=mid) update(u*2,l,mid,x,y,dx,dy);
	
	if(y>mid) update(u*2+1,mid+1,r,x,y,dx,dy);
}

pair<int,int> query(int u,int l,int r,int x)
{
	if(l==r&&l==x) return make_pair(tree[u].x,tree[u].y);
	
	pushdown(u,l,r);
	
	int mid=(l+r)/2;
	
	if(x<=mid) return query(u*2,l,mid,x);
	
	else return query(u*2+1,mid+1,r,x);
}

signed main()
{
	freopen("asm_command.in","r",stdin);
	
	freopen("asm_command.out","w",stdout);
	
	n=read();q=read();
	
	for(int i=1;i<=n;i++) a[i].y=i;
	
	build(1,1,n);

	while(q--)
	{
		int opt,l,r,dx,dy,diao;
		
		opt=read();
		
		if(opt==1)
		{
			l=read();r=read();dx=read();dy=read();
			
			update(1,1,n,l,r,dx,dy);
		}
		
		else if(opt==0)
		{
			l=read();
			
			pair<int,int> ans=query(1,1,n,l);
			
			printf("%.1f %.1f\n",(double)ans.first,(double)ans.second);
		}
		
		else
		{
			l=read();r=read();diao=read();
			
			continue;
		}	
		//for(int i=1;i<=10;i++) cout<<tree[i].y<<" ";
	}
	
	return 0;
}