求助各位大佬!!!这份代码有什么问题?
查看原帖
求助各位大佬!!!这份代码有什么问题?
248896
genshy楼主2020/6/11 21:33
 #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,q,k,x,y;
unsigned int a[105],f[105];
struct jz{
	bool bian[105][105];
}t[35];
jz cheng(jz a, jz b){
	jz c;
	for(int i = 1; i <= n; i++){
		for(int k = 1; k <= n; k++){
			for(int j = 1; j <= n; j++){
				c.bian[i][j] ^= (a.bian[i][k] & b.bian[k][j]);
			}
		}
	}
	return c;
}
void slove(int k){
	unsigned int tmp[105] = {0};
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(t[k].bian[i][j] == 1){
				tmp[i] = tmp[i] ^ a[j];
			}
		}
	}
	for(int i = 1; i <= n; i++){
		a[i] = tmp[i];
	}
}
int main(){
	cin>>n>>m>>q;
	for(int i = 1; i <= n; i++) cin>>f[i];
	for(int i = 1; i <= m; i++){
		cin>>x>>y;
		t[0].bian[x][y] = t[0].bian[y][x] = 1;
	}
	for(int i = 1; i <= 31; i++){
		t[i] = cheng(t[i-1] ,t[i-1]);
	}
	for(int i = 1; i <= q; i++){
		for(int j = 1; j <= n; j++){
			a[j] = f[j];
		}
		cin>>x;
		for(; x > 0; x >>= 1){
			k++;
			if(x&1) slove(k);
		}
		cout<<a[1]<<endl;
	}
	return 0;
}
2020/6/11 21:33
加载中...