diff --git a/BZOJ/2115/2115.cpp b/BZOJ/2115/2115.cpp new file mode 100644 index 00000000..f6bda085 --- /dev/null +++ b/BZOJ/2115/2115.cpp @@ -0,0 +1,69 @@ +#include +#include +#include + +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> 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; +} diff --git a/BZOJ/2115/data/1.in b/BZOJ/2115/data/1.in new file mode 100644 index 00000000..5ba44ff5 --- /dev/null +++ b/BZOJ/2115/data/1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eea4cbf587adf01220dcb39810eeb3510081f4a4d67ac35bc080f075843e2b29 +size 253660 diff --git a/BZOJ/2115/data/1.out b/BZOJ/2115/data/1.out new file mode 100644 index 00000000..9e4a21a7 --- /dev/null +++ b/BZOJ/2115/data/1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a846d72f0f0d38d855e9e046146980cc4891c7b5e0b1e6665bcf6272496c6d7f +size 19 diff --git a/BZOJ/2115/data/10.in b/BZOJ/2115/data/10.in new file mode 100644 index 00000000..bbda0d45 --- /dev/null +++ b/BZOJ/2115/data/10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:443367eead9f23a6a3ab931821dc0116b8265aabbbd645ef1591b3db73f42ca8 +size 2606765 diff --git a/BZOJ/2115/data/10.out b/BZOJ/2115/data/10.out new file mode 100644 index 00000000..eed92035 --- /dev/null +++ b/BZOJ/2115/data/10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c093ea2966434c9dd37c9285bd7f6bae0034b35440d8d83496210c6d457d368a +size 19 diff --git a/BZOJ/2115/data/2.in b/BZOJ/2115/data/2.in new file mode 100644 index 00000000..1becae7f --- /dev/null +++ b/BZOJ/2115/data/2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43e1044028e3e0e755c0d4f6697dbe11f70e6a997c56c4beabe9651a06c25e5b +size 814316 diff --git a/BZOJ/2115/data/2.out b/BZOJ/2115/data/2.out new file mode 100644 index 00000000..d32f3d04 --- /dev/null +++ b/BZOJ/2115/data/2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7fcdf7f0493b96801ab54145b60fe081e687a584d07e38c816d8a0a14e19e4f1 +size 19 diff --git a/BZOJ/2115/data/3.in b/BZOJ/2115/data/3.in new file mode 100644 index 00000000..c32af260 --- /dev/null +++ b/BZOJ/2115/data/3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76b3b85547c3a5fe79afa9ac6a08a5cb67c6527f5694fba8ffd95e7a8d2ff7c6 +size 10226 diff --git a/BZOJ/2115/data/3.out b/BZOJ/2115/data/3.out new file mode 100644 index 00000000..2a64ec1f --- /dev/null +++ b/BZOJ/2115/data/3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ce58ba23c8870572c6e4b683192fd0367665240ccfca68f2f77f04a889f47185 +size 20 diff --git a/BZOJ/2115/data/4.in b/BZOJ/2115/data/4.in new file mode 100644 index 00000000..14a295b6 --- /dev/null +++ b/BZOJ/2115/data/4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5802af5243905459de2edad765c5adc9301416d33ab2fef6af96f8fb3594144 +size 1367965 diff --git a/BZOJ/2115/data/4.out b/BZOJ/2115/data/4.out new file mode 100644 index 00000000..3e9db9a8 --- /dev/null +++ b/BZOJ/2115/data/4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:874ee1aa5f87dc4f4e754084d48c96a481810871688f79646b8e4c9e352b3421 +size 19 diff --git a/BZOJ/2115/data/5.in b/BZOJ/2115/data/5.in new file mode 100644 index 00000000..8206099d --- /dev/null +++ b/BZOJ/2115/data/5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0144c2b435f1a7b0ad97058a25e5a7832ba5a341d40ecab62cbb4b824c3a8495 +size 4754 diff --git a/BZOJ/2115/data/5.out b/BZOJ/2115/data/5.out new file mode 100644 index 00000000..92309e50 --- /dev/null +++ b/BZOJ/2115/data/5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bac85b658299ed68bc6c019338986684df630a60282276eab3fefd344271e947 +size 6 diff --git a/BZOJ/2115/data/6.in b/BZOJ/2115/data/6.in new file mode 100644 index 00000000..0ffdb564 --- /dev/null +++ b/BZOJ/2115/data/6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de611a75dd9216fcfe4e9c3a6eff7eb193eb462da3ebacdfc6d8eb80e5f36a98 +size 2787315 diff --git a/BZOJ/2115/data/6.out b/BZOJ/2115/data/6.out new file mode 100644 index 00000000..c54d9c9d --- /dev/null +++ b/BZOJ/2115/data/6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb6bc74c0ae448a2c0869dfac8aedfaeafcf03bd74721d30fdaf7187ab9284f0 +size 20 diff --git a/BZOJ/2115/data/7.in b/BZOJ/2115/data/7.in new file mode 100644 index 00000000..731f1941 --- /dev/null +++ b/BZOJ/2115/data/7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:482ff59215a4644d933fe7f5378ddf947743e31611efde9f5b8120f0d027853d +size 2749134 diff --git a/BZOJ/2115/data/7.out b/BZOJ/2115/data/7.out new file mode 100644 index 00000000..5693374e --- /dev/null +++ b/BZOJ/2115/data/7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe371d2cafcf1e03cf94fec6ab35f22d72709d850e60288fae411fd1cfdeff57 +size 19 diff --git a/BZOJ/2115/data/8.in b/BZOJ/2115/data/8.in new file mode 100644 index 00000000..ac28745b --- /dev/null +++ b/BZOJ/2115/data/8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d22f8fd1549411430acc12bf3e90a3f292842168496bcc57394c882b449ebf57 +size 9750 diff --git a/BZOJ/2115/data/8.out b/BZOJ/2115/data/8.out new file mode 100644 index 00000000..cf9003a5 --- /dev/null +++ b/BZOJ/2115/data/8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e63d46acab5e7455b0d755b9d915365b9e09a9261030e5dfbd4cb17d1a6b082f +size 5 diff --git a/BZOJ/2115/data/9.in b/BZOJ/2115/data/9.in new file mode 100644 index 00000000..6919a9fe --- /dev/null +++ b/BZOJ/2115/data/9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c88b8d8426f08899d03f7b8c9d0d01d9400bb77fb601f5c0fb20a0b040a599b9 +size 20459 diff --git a/BZOJ/2115/data/9.out b/BZOJ/2115/data/9.out new file mode 100644 index 00000000..1ce54408 --- /dev/null +++ b/BZOJ/2115/data/9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db7f4ee565c76bd1603dd259e48768934ce43b057704ce7b763244172f02bcc2 +size 19