0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

2115. [Wc2011] Xor

https://hydro.ac/d/bzoj/record/6322efd8bdf9bc31d160a3c0
This commit is contained in:
Baoshuo Ren 2022-09-15 17:27:26 +08:00
parent a4335d561f
commit 65803a3023
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
21 changed files with 129 additions and 0 deletions

69
BZOJ/2115/2115.cpp Normal file
View File

@ -0,0 +1,69 @@
#include <iostream>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 50005;
int n, m;
bool vis[N];
unsigned long long p[N], dep[N], ans;
std::vector<std::pair<int, unsigned long long>> g[N];
inline void insert(unsigned long long x) {
for (int i = 60; ~i; i--) {
if (x & (1ull << i)) {
if (p[i]) {
x ^= p[i];
} else {
p[i] = x;
return;
}
}
}
}
void dfs(int u, unsigned long long sum) {
vis[u] = true;
dep[u] = sum;
for (auto e : g[u]) {
int v = e.first;
unsigned long long w = e.second;
if (vis[v]) insert(sum ^ dep[v] ^ w);
else dfs(v, sum ^ w);
}
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int s, t;
unsigned long long d;
cin >> s >> t >> d;
g[s].emplace_back(t, d);
g[t].emplace_back(s, d);
}
dfs(1, 0);
ans = dep[n];
for (int i = 60; ~i; i--) {
if ((ans ^ p[i]) > ans) ans ^= p[i];
}
cout << ans << endl;
return 0;
}

BIN
BZOJ/2115/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2115/data/9.out (Stored with Git LFS) Normal file

Binary file not shown.