結果

問題 No.3482 Quod Erat Demonstrandum
コンテスト
ユーザー kidodesu
提出日時 2026-03-27 21:49:24
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 772 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 209 ms
コンパイル使用メモリ 85,632 KB
実行使用メモリ 119,868 KB
最終ジャッジ日時 2026-03-27 21:49:48
合計ジャッジ時間 15,553 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 17 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def main():
    n, m = list(map(int, input().split()))
    node = [[] for _ in range(n)]
    for _ in range(m):
        u, v, x = list(map(lambda x: int(x)-1, input().split()))
        node[u].append((v, x))
    D = [-1] * n
    E = [-1] * n
    E[0] = 0
    D[0] = 0
    B = [0]
    while A:= B:
        B = []
        for now in A:
            for nxt, x in node[now]:
                if D[nxt] == -1:
                    D[nxt] = D[now]+1
                    E[nxt] = E[now]^x
                    B.append(nxt)
    if E[n-1] == -1:
        print("Unknown")
        return 0
    elif E[n-1] == 0:
        print("Same")
        return D[n-1]
    else:
        print("Different")
        return D[n-1]

for _ in range(int(input())):
    ans = main()
    if ans: print(ans)
0