比赛 Asm.Def战记之圣地亚哥“杯2015 评测结果 AAWWWWWWWW
题目名称 Asm.Def的命令 最终得分 20
用户昵称 ifAandBisC 运行时间 0.461 s
代码语言 C++ 内存使用 15.58 MiB
提交时间 2015-10-31 11:11:29
显示代码纯文本
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define iii 101010

using namespace std;
int n;
struct oup {double x,y;}s[iii],f[iii];

int lowbit (int x) {return x&-x;}
void add (int a,int b,int c,int d)
{
	while (b)
	{
		f[b].x+=c;
		f[b].y+=d;
		b-=lowbit(b);
	}
	while (a)
	{
		a-=lowbit(a);
		f[a].x-=c;
		f[a].y-=d;
	}
}
void search (int a)
{
	int x=s[a].x,y=s[a].y;
	while (a<=n)
	{
		x+=f[a].x;
		y+=f[a].y;
		a+=lowbit(a);
	}
	printf ("%d.0 %d.0\n",x,y);
}
int main ()
{
	freopen ("asm_command.in","r",stdin);
	freopen ("asm_command.out","w",stdout);
	int m,t,a,b,c,d;
	scanf ("%d%d",&n,&m);
	for (int i=1;i<=n;i++) s[i].x=0, s[i].y=i;
	for (int i=1;i<=m;i++)
	{
		scanf ("%d",&t);
		if (t==0)
		{
			scanf ("%d",&a);
			search (a);
		}
		if (t==1)
		{
			scanf ("%d%d%d%d",&a,&b,&c,&d);
			add (a,b,c,d);
		}
		if (t==2)
		{
			printf ("-1.0 -2.0\n");
			printf ("-2.0 -2.0\n");
			printf ("-5.0 0.0\n");
			return 0;
		}
	}
	return 0;
}
/*
5 5
1 1 3 -2 0
0 2
0 1
0 2
0 5
*/