Submission #63556253


Source Code Expand

Copy
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
N, M = map(int, input().split())
grid = defaultdict(list)
visit = [0 for i in range(11)]
for i in range(M):
u, v, w = map(int, input().split())
grid[u].append((v, w))
grid[v].append((u, w))
ans = 10**60
def dfs(p, x):
if p == N:
global ans
ans = min(ans, x)
return
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)

N, M = map(int, input().split())
grid = defaultdict(list)

visit = [0 for i in range(11)]

for i in range(M):
  u, v, w = map(int, input().split())
  grid[u].append((v, w))
  grid[v].append((u, w))

ans = 10**60

def dfs(p, x):
  if p == N:
    global ans
    ans = min(ans, x)
    return
  for j, w in grid[p]:
    if visit[j]:
      continue
    visit[j] = 1
    dfs(j, x^w)
    visit[j] = 0

visit[1] = 1
dfs(1, 0)
      
print(ans)

Submission Info

Submission Time
Task D - Minimum XOR Path
User Baytool
Language Python (PyPy 3.10-v7.3.12)
Score 400
Code Size 543 Byte
Status AC
Exec Time 109 ms
Memory 83156 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 67 ms 76716 KB
00_sample_01.txt AC 70 ms 77188 KB
00_sample_02.txt AC 71 ms 76836 KB
01_test_00.txt AC 67 ms 76712 KB
01_test_01.txt AC 67 ms 76876 KB
01_test_02.txt AC 70 ms 76836 KB
01_test_03.txt AC 71 ms 76856 KB
01_test_04.txt AC 70 ms 76804 KB
01_test_05.txt AC 70 ms 77024 KB
01_test_06.txt AC 72 ms 76960 KB
01_test_07.txt AC 67 ms 76864 KB
01_test_08.txt AC 73 ms 76892 KB
01_test_09.txt AC 76 ms 81508 KB
01_test_10.txt AC 70 ms 77052 KB
01_test_11.txt AC 77 ms 81900 KB
01_test_12.txt AC 73 ms 76892 KB
01_test_13.txt AC 74 ms 81500 KB
01_test_14.txt AC 77 ms 81916 KB
01_test_15.txt AC 84 ms 83156 KB
01_test_16.txt AC 68 ms 76852 KB
01_test_17.txt AC 86 ms 83020 KB
01_test_18.txt AC 71 ms 76820 KB
01_test_19.txt AC 109 ms 82856 KB
01_test_20.txt AC 91 ms 82836 KB
01_test_21.txt AC 98 ms 83048 KB
01_test_22.txt AC 92 ms 82700 KB
01_test_23.txt AC 92 ms 83068 KB
01_test_24.txt AC 72 ms 76788 KB
01_test_25.txt AC 68 ms 76840 KB
01_test_26.txt AC 70 ms 76720 KB
01_test_27.txt AC 72 ms 76820 KB
01_test_28.txt AC 67 ms 77104 KB


2025-04-04 (Fri)
05:21:49 +00:00