全re求调(555)
  • 板块P2068 统计和
  • 楼主2020qlszd
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/9/24 17:24
  • 上次更新2023/11/2 18:17:16
查看原帖
全re求调(555)
1061169
2020qlszd楼主2023/9/24 17:24
#include<bits/stdc++.h>
using namespace std;
long long n,w,ans=0;
char qwq;
int b,c;
long long pos[500002],sum[500002];
int fuck(long long awa) {
	return awa&(-awa);
}
void xg(long long x,long long y) {
	while(x<=y) {
		pos[x]+=y;
		x+=fuck(x);
	}
	return;
}
int cx(long long x,long long y) {
	while(x>0) {
		y+=pos[x];
		x-=fuck(x);
	}
	return y;
}
int jfjf(long long xxx,long long yyy){
	return cx(yyy,0)-cx(xxx-1,0);
}
signed main() {
	scanf("%lld%lld",&n,&w) ;
	for(int i=1; i<=w ; i++) {
		cin>>qwq>>b>>c;
		if(qwq == 'x') {
			xg(b,c);
		} else if(qwq == 'y') {
			ans++;
			sum[ans]=jfjf(b,c);
		}
	}
	for(int i=1;i<=ans;i++){
		cout<<sum[i]<<endl;
	}
	return 0;
}
2023/9/24 17:24
加载中...