文件目录

#include <bits/stdc++.h>
using namespace std;
long long S = 0, f = 1e16;
long long g[505][505];
int n, m, s, t, d;
int main()
{
    for (int i = 1; i <= 500; i++)
        for (int j = 1; j <= 500; j++)
            if (i == j)
                g[i][j] = 0;
            else
                g[i][j] = f;
    cin >> n >> m;
    while (m--)
    {
        scanf("%d%d%d", &s, &t, &d);
        if (g[s][t] > d)
            g[s][t] = d;
    }
    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                if (g[i][k] != f && g[k][j] != f && g[i][j] > g[i][k] + g[k][j])
                {
                    g[i][j] = g[i][k] + g[k][j];
                }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            S ^= g[i][j] + f;
    cout << S;
    return 0;
}