比赛 Asm.Def战记之圣地亚哥“杯2015 评测结果 AAAAWWEEEE
题目名称 Asm.Def的命令 最终得分 40
用户昵称 pppoooiiizzy 运行时间 1.084 s
代码语言 C++ 内存使用 0.35 MiB
提交时间 2015-10-31 10:48:11
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>

const int maxn = 10000 + 5;
using namespace std;

#define rep(i, j, k) for(int i = j; i <= k; i++)
#define drep(i, j, k) for(int i = j; i >= k; i--)
#define INF 0x3fffffff

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

struct poi {
	int x, y;
};

poi c[maxn];
int n, m, Ar, Sa, q, La, Ber;

int lowbit(int x) {return x & -x;}

void updatex(int x, int d)  //Ax + d
{
	for( ; x <= n; x += lowbit(x) )
		c[x].x += d;
}

void updatey(int x, int d)
{
	for( ; x <= n; x += lowbit(x) )
		c[x].y += d;
}


int sumx(int x)
{
	int ret = 0;
	for( ; x > 0; x -= lowbit(x) ) 
		ret += c[x].x;
	return ret;
}

int sumy(int x)
{
	int ret = 0;
	for( ; x > 0; x -= lowbit(x) ) 
		ret += c[x].y;
	return ret;
}

int main()
{
	freopen("asm_command.in", "r", stdin);
	freopen("asm_command.out", "w", stdout);
	n = read(); q = read();
	rep(i, 1, n) updatex(i, 0);
	rep(i, 1, n) updatey(i, i);
	rep(i, 1, q) {
		m = read();
		if( m == 1) {
			Ar = read(), Sa = read(), La = read(), Ber = read();
			rep(j, Ar, Sa) {
				updatex(j, La);
				updatey(j, Ber);
			}
		}
		if( m == 0) {
			Sa = read();
			printf("%0.1f %0.1f\n", (double)sumx(Sa) - (double)sumx(Sa - 1), (double)sumy(Sa) - (double)sumy(Sa - 1));
		}
	}
	return 0;
}