Submission #63523439


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const long double PI = acos(-1);
const ll mod = 998244353;
const int maxn = 2e5 + 7;
const ll P = 133331;
const double eps = 1e-8;
ll qgcd(ll a, ll b) {
return b == 0 ? a : qgcd(b, a % b);
}
ll qpow(ll a, ll b) {
ll ans = 1;
while (b) {
if (b & 1)
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const long double PI = acos(-1);
const ll mod = 998244353;
const int maxn = 2e5 + 7;
const ll P = 133331;
const double eps = 1e-8;

ll qgcd(ll a, ll b) {
    return b == 0 ? a : qgcd(b, a % b);
}

ll qpow(ll a, ll b) {
    ll ans = 1;
    while (b) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

int n, m;
vector<pair<int, ll>> v[15];
ll ans = -1;

void dfs(int cur, int fa, set<int> s, ll res) {
    if (cur == n) {
        if (ans == -1) {
            ans = res;
        }
        ans = min(ans, res);
        return;
    }
    for (auto i: v[cur]) {
        if (i.first == fa) {
            continue;
        }
        set<int> st = s;
        if (st.find(i.first) == st.end()) {
            st.insert(i.first);
            dfs(i.first, cur, st, res ^ i.second);
        }
    }
}

void solve() {
    cin >> n >> m;
    while (m--) {
        ll x, y, z;
        cin >> x >> y >> z;
        v[x].push_back({y, z});
        v[y].push_back({x, z});
    }
    set<int> s;
    s.insert(1);
    dfs(1, 1, s, 0);
    cout << ans;
}

int main() {
//    IOS;
    int T = 1;
//    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

/*



*/

Submission Info

Submission Time
Task D - Minimum XOR Path
User 2021404292
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1481 Byte
Status AC
Exec Time 173 ms
Memory 3688 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 32
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3484 KB
00_sample_01.txt AC 1 ms 3476 KB
00_sample_02.txt AC 1 ms 3416 KB
01_test_00.txt AC 1 ms 3544 KB
01_test_01.txt AC 1 ms 3560 KB
01_test_02.txt AC 1 ms 3544 KB
01_test_03.txt AC 1 ms 3544 KB
01_test_04.txt AC 1 ms 3548 KB
01_test_05.txt AC 1 ms 3616 KB
01_test_06.txt AC 1 ms 3476 KB
01_test_07.txt AC 1 ms 3688 KB
01_test_08.txt AC 1 ms 3408 KB
01_test_09.txt AC 4 ms 3548 KB
01_test_10.txt AC 1 ms 3480 KB
01_test_11.txt AC 4 ms 3456 KB
01_test_12.txt AC 1 ms 3680 KB
01_test_13.txt AC 1 ms 3420 KB
01_test_14.txt AC 4 ms 3552 KB
01_test_15.txt AC 17 ms 3616 KB
01_test_16.txt AC 1 ms 3480 KB
01_test_17.txt AC 86 ms 3616 KB
01_test_18.txt AC 1 ms 3496 KB
01_test_19.txt AC 173 ms 3616 KB
01_test_20.txt AC 173 ms 3492 KB
01_test_21.txt AC 173 ms 3548 KB
01_test_22.txt AC 173 ms 3544 KB
01_test_23.txt AC 173 ms 3568 KB
01_test_24.txt AC 1 ms 3492 KB
01_test_25.txt AC 1 ms 3544 KB
01_test_26.txt AC 1 ms 3460 KB
01_test_27.txt AC 1 ms 3492 KB
01_test_28.txt AC 1 ms 3440 KB


2025-03-22 (Sat)
04:14:27 +00:00