P5522 getchar为什么读不进去
查看原帖
P5522 getchar为什么读不进去
812227
Sunrise_beforeglow楼主2024/9/4 09:33
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int M=(1e5)+10; 
int n,m,c[35][M][5],q,ans,op,l,r,pos,sum;
char ch[M][35];
int lowbit(int x){return x&(-x);}
void add(int a,int x,int k,int h){for(int i=x;i<=m;i+=lowbit(i))c[a][i][h]+=k; }
int get(int a,int x,int h){int s=0;for(int i=x;i>=1;i-=lowbit(i))s+=c[a][i][h];return s;}
int rmq(int a,int l,int r,int h){return get(a,r,h)-get(a,l-1,h);}
signed main()
{	
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>q;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			ch[i][j]=getchar();
			if(ch[i][j]!='?')add(j,i,1,ch[i][j]-'0');
		}
		getchar();
	}
	while(q--)
	{
		cin>>op;
		if(op==0)
		{
			cin>>l>>r;
			sum=1;
			for(int i=1;i<=n;i++)
			{
				int x=rmq(i,l,r,0),y=rmq(i,l,r,1);
				if(x&&y){sum=0;break;}
				else if((!x)&&(!y))sum*=2LL;
			}
			ans^=sum;
		}
		else
		{
			cin>>pos;
			getchar();
			for(int j=1;j<=n;j++)
			{
				if(ch[pos][j]!='?')add(j,pos,-1,ch[pos][j]-'0');
			}
/***************************************/
			for(int j=1;j<=n;j++)
			{
				ch[pos][j]=getchar();//就是这,直接读到下一行去了
				if(ch[pos][j]!='?')add(j,pos,1,ch[pos][j]-'0');
			}
			getchar();
/*************************************/
		}
	}
	cout<<ans;
	return 0;
}
2024/9/4 09:33
加载中...