求大佬来帮我看看为啥全部TLE?
查看原帖
求大佬来帮我看看为啥全部TLE?
222341
twocats楼主2020/5/24 14:39
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,m,q,a,ans,C[N],Y[N],T[N];
vector<int> E[N];

void input(int m)
{
	while(m--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		E[x].push_back(y);
		E[y].push_back(x);
	}
}

void ask(int t)
{
	int p;
	memset(Y,0,sizeof(Y));
	for(int i=1;i<=n;i++)	Y[i]=C[i];
	while(t--)
	{
		for(int i=1;i<=n;i++)
		{
			if(!E[i].empty())	p=Y[E[i][0]];
			for(int j=1;j<E[i].size();j++)	p^=Y[E[i][j]];
			T[i]=p;
		}
		for(int i=1;i<=n;i++)	Y[i]=T[i];
	}
	printf("%d\n",T[1]);
}

int main()
{
//	freopen("magic.in","r",stdin);
//	freopen("magic.out","w",stdout);
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)	scanf("%d",&C[i]);
	input(m);
	while(q--&&scanf("%d",&a)==1)	ask(a);
	return 0;
}
2020/5/24 14:39
加载中...