60pts求助
查看原帖
60pts求助
530991
lpstudio楼主2022/12/18 21:41

已经使用 O(Tn+Tq)\operatorname{O(Tn+Tq)} 的做法了,仍然只有 60pts\operatorname{60pts}

#include<bits/stdc++.h>
using namespace std;
int T,n,sum,q,o,f,k,p;
string s,t;
char ch;
int main()
{
	ios::sync_with_stdio(false);
	cin>>T;	
	while(T--)
	{
		sum=0;
		cin>>n>>q>>s>>t;
		for(int i=0;i<n;i++)
			if(s[i]!=t[i])
			sum++;
		if(sum)
		cout<<"No\n";
		else
		cout<<"Yes\n";
		while(q--)
		{
			cin>>o>>p>>ch;
			if(s[p-1]==t[p-1])
			f=1;
			else
			f=0;
			if(o)
			t[p-1]=ch;
			else
			s[p-1]=ch;
			if(s[p-1]==t[p-1])
			k=1;
			else
			k=0;
			sum+=(f-k);
			if(sum)
			cout<<"No\n";
			else
			cout<<"Yes\n";
		}
	}
} 
2022/12/18 21:41
加载中...