Submission #66749180
Source Code Expand
Copy
def SI(): return input()def NI(): return int(input())def TI(): return map(int, input().split())def TI1(): return map(lambda x: int(x)-1, input().split())def LI(): return list(map(int, input().split()))def LI1(): return list(map(lambda x: int(x)-1, input().split()))def Yes(): print("Yes")def No(): print("No")def YN(flg): print("YNeos"[not flg::2])#from sortedcontainers import SortedSet, SortedList, SortedDictfrom collections import Counter, defaultdict, deque#from bisect import bisect, bisect_left, bisect_right#from itertools import permutations, combinations, product#from math import sqrt, atan, pi, ceil#from heapq import heappush, heappop#from functools import lru_cacheMOD = 998244353N, M = TI()
def SI(): return input()
def NI(): return int(input())
def TI(): return map(int, input().split())
def TI1(): return map(lambda x: int(x)-1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(lambda x: int(x)-1, input().split()))
def Yes(): print("Yes")
def No(): print("No")
def YN(flg): print("YNeos"[not flg::2])
#from sortedcontainers import SortedSet, SortedList, SortedDict
from collections import Counter, defaultdict, deque
#from bisect import bisect, bisect_left, bisect_right
#from itertools import permutations, combinations, product
#from math import sqrt, atan, pi, ceil
#from heapq import heappush, heappop
#from functools import lru_cache
MOD = 998244353
N, M = TI()
G = defaultdict(list)
for _ in range(M):
A, B, W = TI()
A -= 1
B -= 1
G[A].append((B, W))
G[B].append((A, W))
d = [-1]*N
d[0] = 0
X = []
q = deque()
q.append(0)
while q:
u = q.popleft()
for v, w in G[u]:
if d[v] == -1:
d[v] = d[u] ^ w
q.append(v)
else:
a = d[u] ^ d[v] ^ w
for x in X:
a = min(a, a ^ x)
if a != 0:
X.append(a)
X.sort(reverse = True)
ans = d[-1]
for x in X:
ans = min(ans, ans ^ x)
if ans < 0:
print(-1)
else:
print(ans)
Submission Info
| Submission Time | |
|---|---|
| Task | D - XOR Shortest Walk |
| User | yuuki1352 |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 0 |
| Code Size | 1317 Byte |
| Status | WA |
| Exec Time | 92 ms |
| Memory | 83508 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 400 | ||||||
| Status |
|
|
| 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 | 72 ms | 76988 KiB |
| hand_02.txt | AC | 71 ms | 76720 KiB |
| hand_03.txt | WA | 72 ms | 77012 KiB |
| hand_04.txt | AC | 72 ms | 76652 KiB |
| hand_05.txt | WA | 72 ms | 76784 KiB |
| hand_06.txt | WA | 72 ms | 76732 KiB |
| hand_07.txt | WA | 72 ms | 77208 KiB |
| hand_08.txt | WA | 71 ms | 76896 KiB |
| random_01.txt | AC | 72 ms | 76892 KiB |
| random_02.txt | AC | 79 ms | 81552 KiB |
| random_03.txt | AC | 71 ms | 77208 KiB |
| random_04.txt | AC | 76 ms | 76892 KiB |
| random_05.txt | AC | 72 ms | 76960 KiB |
| random_06.txt | AC | 73 ms | 76884 KiB |
| random_07.txt | AC | 71 ms | 76848 KiB |
| random_08.txt | AC | 79 ms | 81364 KiB |
| random_09.txt | AC | 73 ms | 77176 KiB |
| random_10.txt | AC | 83 ms | 81448 KiB |
| random_11.txt | AC | 71 ms | 76848 KiB |
| random_12.txt | AC | 80 ms | 81184 KiB |
| random_13.txt | AC | 80 ms | 81212 KiB |
| random_14.txt | AC | 82 ms | 81568 KiB |
| random_15.txt | AC | 78 ms | 81164 KiB |
| random_16.txt | AC | 73 ms | 76956 KiB |
| random_17.txt | AC | 89 ms | 83192 KiB |
| random_18.txt | AC | 89 ms | 83384 KiB |
| random_19.txt | AC | 90 ms | 83508 KiB |
| random_20.txt | AC | 92 ms | 83204 KiB |
| random_21.txt | AC | 86 ms | 81792 KiB |
| random_22.txt | AC | 87 ms | 81800 KiB |
| sample_01.txt | AC | 73 ms | 76772 KiB |
| sample_02.txt | AC | 73 ms | 76700 KiB |
| sample_03.txt | AC | 73 ms | 76940 KiB |