Computes a path of 1 to N to make the value XOR and maximum on the path.
The XOR is calculated by taking one path at a time and then DFS is processed out of all the rings of XOR and, so for all the xor of the ring and for the linear base, the XOR and the greedy on the arbitrary path out.
Correctness obviously, if the loop is coincident with the selected path, then the coincident part will be XOR two times, and there will be no XOR, which is equivalent to changing a part of the path. If the ring is not coincident with the selected path, then it is equivalent to a point on the path from any point to the ring, and after running a lap from the point of entry loop back, so that the xor of the ring is calculated, and the two-way trip is also because the XOR two times the equivalent of no XOR, do not have to consider.
#include <cstdio> #include <cstring> #include <algorithm>using namespace Std;typedef long ll; const int N = 50003;const int M = 100003;void read (int &k) {k = 0; int fh = 1; char c = GetChar (); for (; c < ' 0 ' | | C > ' 9 '; c = GetChar ()) if (c = = '-') FH = -1;for (; c >= ' 0 ' && C <= ' 9 '; c = GetChar ()) K = (k << 3) + (k <&L T 1) + C-' 0 '; k = k * FH;} void Readll (ll &k) {k = 0; int fh = 1; char c = GetChar (); for (; c < ' 0 ' | | c > ' 9 '; c = GetChar ()) if (c = = '-') FH = -1;for (; c >= ' 0 ' && C <= ' 9 '; c = GetChar ()) K = (k << 3) + (k << 1) + C-' 0 '; k = k * FH;} struct Node {int NXT, to; ll W;} E[m << 1];int N, M, cnt = 0, point[n];ll p[m *, a[63], d[n];bool vis[n];void ins (int x, int y, ll z) {E[++CNT].N XT = Point[x]; e[cnt].to = y; E[CNT].W = Z; POINT[X] = cnt;} void _ (int x) {Vis[x] = 1;for (int i = point[x]; i; i = e[i].nxt) {int v = e[i].to;if (Vis[v]) p[++cnt] = D[v] ^ d[x] ^ e[i ].w;else D[v] = d[x] ^ E[I].W, _ (v);}} int main () {read (n); read (m); int u, v; ll e;for (int i = 1; I <= m; ++i) {Read (u); Read (v); Readll (e); Ins (U, V, e); Ins ( V, u, e);} CNT = 0;_ (1), for (int i = 1; I <= cnt, ++i) for (int j = 1; j >= 0;--j) if ((P[i] >> j) &) {if (!a[j]) {a[ J] = P[i]; break;} else P[i] ^= a[j];} ll ans = d[n];for (int j = max; J >= 0;--j) if (! ( (ans >> j) & 1) && a[j]) ans ^= a[j];p rintf ("%lld\n", ans); return 0;}
PIT-in-place operation priority is QAQ, and the priority of the >> operator does not have a high priority for the "= =" Operator! I am in the reign of the operation again to make fun of 1h+, the game again such a tease is really going to roll the TWT. Rolling is really cruel ah, say go away, sometimes it's too late to react QWQ
"Bzoj 2115" "WC 2011" Xor