Submission #66735422


Source Code Expand

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
from atcoder.dsu import DSU
n, m = na()
B = 1 << 10

g = [[] for i in range(n * B)]
for i in range(m):
    a, b, w = na()
    a -= 1
    b -= 1
    for j in range(B):
        g[a * B + j].append(b * B  + (j ^ w))

dist = [0] * (n * B)
q = [0]
dist[0] = 1
while q:
    x = q.pop()
    for y in g[x]:
        if dist[y] == 0:
            dist[y] = 1
            q.append(y)
for i in range(B):
    if dist[(n-1) * B + i]:
        print(i)
        break
else:
    print(-1)

Submission Info

Submission Time
Task D - XOR Shortest Walk
User tassei903
Language Python (PyPy 3.10-v7.3.12)
Score 400
Code Size 855 Byte
Status AC
Exec Time 716 ms
Memory 201756 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 33
Set Name Test Cases
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
Case Name Status Exec Time Memory
hand_01.txt AC 137 ms 84296 KiB
hand_02.txt AC 137 ms 84588 KiB
hand_03.txt AC 138 ms 84564 KiB
hand_04.txt AC 130 ms 84872 KiB
hand_05.txt AC 134 ms 85148 KiB
hand_06.txt AC 139 ms 85500 KiB
hand_07.txt AC 139 ms 85504 KiB
hand_08.txt AC 140 ms 85492 KiB
random_01.txt AC 139 ms 85812 KiB
random_02.txt AC 204 ms 141380 KiB
random_03.txt AC 138 ms 85472 KiB
random_04.txt AC 173 ms 110680 KiB
random_05.txt AC 133 ms 85480 KiB
random_06.txt AC 162 ms 106008 KiB
random_07.txt AC 138 ms 85276 KiB
random_08.txt AC 201 ms 139852 KiB
random_09.txt AC 140 ms 85704 KiB
random_10.txt AC 236 ms 172316 KiB
random_11.txt AC 138 ms 85572 KiB
random_12.txt AC 202 ms 141688 KiB
random_13.txt AC 169 ms 95700 KiB
random_14.txt AC 236 ms 108160 KiB
random_15.txt AC 153 ms 86124 KiB
random_16.txt AC 171 ms 116748 KiB
random_17.txt AC 265 ms 201756 KiB
random_18.txt AC 263 ms 201484 KiB
random_19.txt AC 716 ms 200812 KiB
random_20.txt AC 384 ms 168632 KiB
random_21.txt AC 370 ms 168756 KiB
random_22.txt AC 357 ms 169156 KiB
sample_01.txt AC 138 ms 85556 KiB
sample_02.txt AC 136 ms 85312 KiB
sample_03.txt AC 171 ms 122828 KiB