提出 #66762255


ソースコード 拡げる

// #pragma GCC target("avx2")
#pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<sys/time.h>
// #include<atcoder/scc>
// #include<atcoder/segtree>

using namespace std;

// using mint = atcoder::modint1000000007;


using P = pair<int, int>;


const int M = 998244353;
const long long LM = 1LL << 60;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<vector<P>> edge(n);
    for (int i = 0; i < m; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        --u;
        --v;
        edge[u].emplace_back(w, v);
    }
    vector<vector<bool>> f(n, vector<bool>(1024));
    f[0][0] = true;
    queue<P> q;
    q.emplace(0, 0);
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
        for (auto&& e : edge[p.second]) {
            if (!f[e.second][p.first ^ e.first]) {
                f[e.second][p.first ^ e.first] = true;
                q.emplace(p.first ^ e.first, e.second);
            }
        }
    }
    for (int i = 0; i < 1024; ++i) {
        if (f[n - 1][i]) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
    return 0;
}

提出情報

提出日時
問題 D - XOR Shortest Walk
ユーザ riantkb
言語 C++ 20 (gcc 12.2)
得点 400
コード長 1268 Byte
結果 AC
実行時間 7 ms
メモリ 3920 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 33
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 1 ms 3384 KiB
hand_02.txt AC 1 ms 3636 KiB
hand_03.txt AC 1 ms 3380 KiB
hand_04.txt AC 1 ms 3512 KiB
hand_05.txt AC 1 ms 3584 KiB
hand_06.txt AC 1 ms 3580 KiB
hand_07.txt AC 1 ms 3516 KiB
hand_08.txt AC 1 ms 3512 KiB
random_01.txt AC 1 ms 3444 KiB
random_02.txt AC 1 ms 3652 KiB
random_03.txt AC 1 ms 3500 KiB
random_04.txt AC 1 ms 3600 KiB
random_05.txt AC 1 ms 3516 KiB
random_06.txt AC 1 ms 3536 KiB
random_07.txt AC 1 ms 3516 KiB
random_08.txt AC 1 ms 3636 KiB
random_09.txt AC 1 ms 3444 KiB
random_10.txt AC 1 ms 3776 KiB
random_11.txt AC 1 ms 3436 KiB
random_12.txt AC 1 ms 3736 KiB
random_13.txt AC 3 ms 3676 KiB
random_14.txt AC 5 ms 3920 KiB
random_15.txt AC 2 ms 3512 KiB
random_16.txt AC 1 ms 3652 KiB
random_17.txt AC 1 ms 3748 KiB
random_18.txt AC 1 ms 3824 KiB
random_19.txt AC 5 ms 3892 KiB
random_20.txt AC 4 ms 3748 KiB
random_21.txt AC 7 ms 3672 KiB
random_22.txt AC 6 ms 3676 KiB
sample_01.txt AC 1 ms 3440 KiB
sample_02.txt AC 1 ms 3512 KiB
sample_03.txt AC 1 ms 3716 KiB