usingnamespace std; constint N = 1e5 + 5; int num[N], n, k, q, zero;
boolinsert(int x){ for (int i = 62; i >= 0; i--) { if ((x >> i & 1) == 0) continue; if (num[i] == 0) { num[i] = x; returntrue; } else x ^= num[i]; } returnfalse; }
signedmain(){ cin >> n; for (int i = 0; i < n; i ++) { int x; cin >> x; if (!insert (x)) zero ++; } cin >> q; while (q --) { cin >> k; k >>= zero; vector <int> v; for (int i = 0; i <= 62; i++) if (num[i]) v.push_back (num[i]); int m = v.size();
int ans = 0; for (int i = m-1; i >= 0; i--) { if (k >> i & 1) ans = max (ans, ans^v[i]); else ans = min (ans, ans^v[i]); }
constint N = 5e4 + 5; ll dis[N]; int n, m; bool vis[N]; vector <pii> e[N];
structlinear_basis { ll num[63]; boolinsert(ll x){ for (int i = 62; i >= 0; i--) { if ((x >> i & 1ll) == 0) continue; if (num[i] == 0) { num[i] = x; returntrue; } else x ^= num[i]; } returnfalse; }
ll querymin(ll x){ for (int i = 62; i >= 0; i --) { x = min (x, x ^ num[i]); } return x; }
ll querymax(ll x){ for (int i = 62; i >= 0; i --) { x = max (x, x ^ num[i]); } return x; } }T;
voiddfs(int u){ //枚举所有环 vis[u] = true; for (auto vi : e[u]) { int v = vi.first; ll w = vi.second; if (!vis[v]) { dis[v] = dis[u] ^ w; dfs (v); } else { T.insert (dis[u] ^ dis[v] ^ w); //环的异或和 } } }
intmain(){ cin >> n >> m; for (int i = 0; i < m; i ++) { int u, v; ll w; cin >> u >> v >> w; e[u].push_back ({v, w}); e[v].push_back ({u, w}); } dfs (1); cout << T.querymax(dis[n]) << endl; }
usingnamespace std; typedef pair<int, int> pii; constint N = 20; int c[N], n, m;
signedmain(){ cin >> n; m = 1 << n; vector <pii> v; for (int i = 1; i < m; i ++) { int x; cin >> x; v.push_back ({x, i}); } sort (v.begin(), v.end()); //按照花费从小到大排
int ans = 0; vector <int> t(n+1, 0); //线性基 for (auto vi : v) { int val = vi.first, x = vi.second; for (int i = 0; i < n; i ++) { if ((x >> i & 1) == 0) continue; if (t[i] == 0) { //更新线性基 ans += val; t[i] = x; break; } else x ^= t[i]; } }