求助各位大佬,为什么会RE
查看原帖
求助各位大佬,为什么会RE
755114
CD43楼主2023/12/23 22:40

RT,调到头皮发麻

#include<bits/stdc++.h>
#define endl "\n"
#define mp make_pair
#define int long long
using namespace std;
const long long mod=10000000007;
void write__int128(__int128 s)
{
    if(s>=10)write__int128(s/10);  
    cout<<(char)(s%10+'0');
}
void write__int128(unsigned __int128 s)
{
    if(s>=10)write__int128(s/10);  
    cout<<(char)(s%10+'0');
}
bool cmp1(char a,char b)
{
	return a<b;
}
bool cmp2(char a,char b)
{
	return a>b;
}
int c,n,m,p;
int x[10001],y[10001];
bool compare(int a[],int b[],bool t)
{
	if(t)swap(m,n);
	int l1=1,l2=1;
	int r1=n,r2=m;
	while(l1<=l2&&(l1<=n&&l2<=m))
	{
		if(a[l1]>b[l2])l2++;
		else l1++;
	}
	while(r1>=r2&&(r1>=1&&r2>=1))
	{
		if(a[r1]>b[r2])r2--;
		else r1--;
	}
//	cout<<endl<<l1<<' '<<l2<<':'<<r1<<' '<<r2;
	if(t)swap(m,n);
	
	return l1<=l2&&r1>=r2;
}
signed main()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(0);
	cin>>c>>n>>m>>p;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i];
	}
	for(int i=1;i<=m;i++)
	{
		cin>>y[i];
	}
	cout<<(compare(y,x,1)|compare(x,y,0));
	int nx,ny,t,q,a[10001],b[10001];
	while(p--)
	{
		cin>>nx>>ny;
		for(int i=1;i<=n;i++)
		{
			a[i]=x[i];
		}
		for(int i=1;i<=m;i++)
		{
			b[i]=y[i];
		}
		for(int i=1;i<=nx;i++)
		{
			cin>>t>>q;
			a[t]=q;
		}
		for(int i=1;i<=ny;i++)
		{
			cin>>t>>q;
			b[t]=q;
		}
		
		
//		for(int i=1;i<=n;i++)
//		{
//			cout<<a[i]<<' ';
//		}
//		cout<<endl;
//		for(int i=1;i<=m;i++)
//		{
//			cout<<b[i]<<' ';
//		}
//		cout<<endl;
//		
		cout<<(compare(b,a,1)|compare(a,b,0));
	}
	return 0;
	exit(0);
}

2023/12/23 22:40
加载中...