ACwing.228 异或(线性基)

2021-03-08 13:27

阅读:584

标签:math   std   异或   queue   size   query   break   mes   线性   

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include


using namespace std;
typedef long long ll;
const int N = 5e4 + 105;
const int mod = 10000;
const int P = 9999;
const double Pi = acos(- 1.0);
const int INF = 0x3f3f3f3f;


inline int read() {
	char ch = getchar(); int x = 0, f = 1;
	while (ch  ‘9‘) {
		if (ch == ‘-‘) f = -1;
		ch = getchar();
	}
	while (‘0‘ = 0; -- i)
			if(val & (1ll = 0; -- i){
		    ll che = res ^ lba[i];
			if(che > res) res^=lba[i];
		}
		return res;
	}
};

//图论基本模板

struct Edge{
	int to;
	ll c;
	int nxt;
}edge[N * 4];

int head[N], cnt = 0;
int n, m;

inline void add(int u, int v, ll w){
	edge[cnt].to = v;
	edge[cnt].c = w;
	edge[cnt].nxt = head[u];
	head[u] = cnt ++;
}

//main()
ll res;
int vis[N];
L_B lb;
ll dis[N];

void dfs(int u, int pre){
	vis[u] = 1;
	for(int i = head[u]; i != -1; i = edge[i].nxt){
		int v = edge[i].to;
		ll w = edge[i].c;
		if(v == pre) continue;
		if(vis[v]){
			lb.Insert(w ^ dis[u] ^ dis[v]);
			continue;
		}
		dis[v] = dis[u] ^ w;
		dfs(v, u);
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	memset(head, -1, sizeof(head));
	for(int i = 1; i 

ACwing.228 异或(线性基)

标签:math   std   异或   queue   size   query   break   mes   线性   

原文地址:https://www.cnblogs.com/A-sc/p/12791225.html


评论


亲,登录后才可以留言!