比赛 EYOI暨SBOI暑假快乐赛5th 评测结果 TTTTTTTTTT
题目名称 Sergey and Subway 最终得分 0
用户昵称 lavey 运行时间 10.000 s
代码语言 C++ 内存使用 43.88 MiB
提交时间 2022-06-29 11:52:42
显示代码纯文本
#include<bits/stdc++.h>
#define rap(x,y,z) for(int x=y;x<=z;x++)
#define ull unsigned long long
#define ll long long
using namespace std;
inline int read()
{
	int x=0;bool flag=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-')flag=0;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	if(flag) return x;
	return ~(x-1);
} 
inline void write(int x)
{
	if(x<0) {x=~(x-1);putchar('-');}
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
//////////////////
const int MAXN=1e7+50;
int nc,mc;
int f[MAXN];
inline int lowbit(int x){return x&-x;}
inline void ADD(int x,int ad)
{
	while(x<=nc)
	{
		f[x]+=ad;
		x+=lowbit(x);
	}
	return;
}
inline void FIND(int x)
{
	int ans=0;
	while(x)
	{
		ans+=f[x];
		x-=lowbit(x);
	}
	write(ans);
	putchar(10);
	return;
}
int main()
{
//    freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	nc=read();
	mc=read();
	int s1,s2;
	rap(i,1,mc)
	{
		s1=read();
		if(s1) s1=read(),FIND(s1);
		else s1=read(),s2=read(),ADD(s1,1),ADD(s2+1,-1);
	}
    return 0;
}