为什么会出问题呢
查看原帖
为什么会出问题呢
627304
Xujingyang楼主2023/11/11 20:42
#include<bits/stdc++.h>
using namespace std;
bool pd=1;
long long x,y,l,r,n,a[2004],m,t,k,hh=1,xw=999999999,yw=999999999,temp;
int search(int t,int j,int r){
	for (int i=j;i<=r;i++)
	{
		if (a[i]==t)
		return (i-l);
	}
	return 999999999;
}
int main(){
//	freopen("mahjong.in","r",stdin);
//	freopen("mahjong.out","w",stdout);
	cin>>n>>m>>k;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for (int i=1;i<=m;i++)
	{
		hh=1;
		cin>>x>>y>>l>>r;
				if (y!=x)
				{
					temp=search(x,l+1,r);
					if (temp<xw)
					{
						xw=temp;
					}
				}
				if (x!=y)
				{
					temp=search(y,l+1,r);
					if (temp<yw)
					{
						yw=temp;
					}
				}
		for (int j=l;j<=r;j++)
		{
			t=a[j];
			if (hh==1)//A
			{
				hh=0;
				t=a[j];
				if (x==t)
				{
					cout<<"A"<<endl;
					pd=0;
					break;
				}
				if (y==t)
				x=t;
				else if (y!=x)
				{
					temp=search(t,j+1,r);
					if (temp<xw)
					{
						x=t;
						xw=temp;
					}
				}
			}
			else//B
			{
				hh=1;
				if (y==t)
				{
					cout<<"B"<<endl;
					pd=0;
					break;
				}
				if (x==t)
				y=t;
				else if (x!=y)
				{
					temp=search(t,j+1,r);
					if (temp<yw)
					{
						y=t;
						yw=temp;
					}
				}
			}
		}
		if (pd==1)
		cout<<"D"<<endl;
		pd=1;
	}
	return 0;
}

怎么寄掉的...

2023/11/11 20:42
加载中...