hrbust 1161 树状数组模版
来源:互联网 发布:linux系统克隆 编辑:程序博客网 时间:2024/05/18 01:50
#include<cstdio>#include<cstring>int c[100001]={};int cool[100001]={};int n;int lowbit(int x){ return x&(-x);}void add(int i,int d){ while(i<=n) { c[i]+=d; i+=lowbit(i); }}int getsum(int i){ int sum=0; while(i>0) { sum+=c[i]; i-=lowbit(i); } return sum;}int main(){ int t; scanf("%d",&t); for(int times=1;times<=t;times++) { printf("Case %d:\n",times); memset(c,0,sizeof(c)); memset(cool,0,sizeof(cool)); int q,t; scanf("%d%d%d",&n,&q,&t); int j=0; while(q--) { char temp[10]; scanf("%s",temp); if(temp[0]=='A') { j++; int x; scanf("%d",&x); //printf("%d\n",j-cool[x]); //printf("%d %d\n",j,cool[x]); if(cool[x]==0) { cool[x]=j; } else if(j-cool[x]<t) { //printf("fuck\n"); add(x,1); } else if(j-cool[x]>=t) { cool[x]=j; } } if(temp[0]=='Q') { int a,b; scanf("%d%d",&a,&b); if(a>b) { int c=a; a=b; b=c; } printf("%d\n",getsum(b)-getsum(a-1)); } } } return 0;}
0 0
- hrbust 1161 树状数组模版
- 树状数组模版
- 树状数组模版
- 树状数组模版
- 树状数组模版
- 树状数组(模版)
- 树状数组 模版
- 树状数组模版
- 二维树状数组模版
- 树状数组模版
- 树状数组模版
- 树状数组模版
- 树状数组的模版
- 算法模版 树状数组
- 树状数组模版
- 树状数组模版
- hrbust 1794 敌兵布阵 树状数组
- Hrbust 1794敌兵布阵(树状数组应用)
- 监听网络的广播接收者接收两次解决方案
- 前端面试需要掌握的一些知识点
- UVA - 10306 e-Coins
- PE 6 Sum square difference
- 1068. Find More Coins (30)
- hrbust 1161 树状数组模版
- 【计算机基础】 常用的排序算法的时间复杂度和空间复杂度
- Maximum Subsequence Sum【PAT 1007题】---简单的动态规划
- (二)yii使用原生html不使用yii生成html表单如何忽略m层验证无法通过
- js深层次知识点
- Mysql主从复制总结
- hrbust 1400 排序+求逆序
- 班级主页代码
- QT点击按钮实现按钮名的改变