結果

問題 No.1473 おでぶなおばけさん
ユーザー 👑 timitimi
提出日時 2021-04-26 15:55:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 921 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 181,448 KB
最終ジャッジ日時 2023-09-18 08:48:42
合計ジャッジ時間 30,774 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,712 KB
testcase_01 AC 92 ms
71,688 KB
testcase_02 AC 861 ms
125,376 KB
testcase_03 AC 712 ms
117,376 KB
testcase_04 AC 541 ms
104,340 KB
testcase_05 AC 325 ms
85,968 KB
testcase_06 AC 753 ms
121,616 KB
testcase_07 AC 931 ms
131,656 KB
testcase_08 AC 937 ms
130,948 KB
testcase_09 AC 901 ms
129,908 KB
testcase_10 AC 418 ms
92,912 KB
testcase_11 AC 420 ms
92,492 KB
testcase_12 AC 449 ms
92,896 KB
testcase_13 AC 300 ms
86,992 KB
testcase_14 AC 247 ms
85,540 KB
testcase_15 AC 381 ms
91,416 KB
testcase_16 AC 402 ms
91,356 KB
testcase_17 AC 133 ms
78,056 KB
testcase_18 AC 144 ms
78,336 KB
testcase_19 AC 465 ms
91,436 KB
testcase_20 AC 731 ms
114,076 KB
testcase_21 AC 655 ms
104,064 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 704 ms
114,820 KB
testcase_27 WA -
testcase_28 AC 875 ms
130,216 KB
testcase_29 WA -
testcase_30 AC 675 ms
109,028 KB
testcase_31 AC 778 ms
131,932 KB
testcase_32 AC 556 ms
121,164 KB
testcase_33 AC 519 ms
111,576 KB
testcase_34 AC 403 ms
96,100 KB
testcase_35 AC 371 ms
93,936 KB
testcase_36 WA -
testcase_37 AC 650 ms
110,652 KB
testcase_38 WA -
testcase_39 AC 418 ms
93,016 KB
testcase_40 AC 414 ms
93,016 KB
testcase_41 AC 405 ms
91,160 KB
testcase_42 AC 410 ms
91,296 KB
testcase_43 AC 289 ms
105,540 KB
testcase_44 AC 289 ms
105,592 KB
testcase_45 AC 289 ms
105,556 KB
testcase_46 TLE -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int, input().split())
D=[]
for i in range(M):
  s,t,d=map(int, input().split())
  D.append((d,s,t))
D=sorted(D)[::-1]
par=[i for i in range(N)]
rank=[0]*(N)
friend=[0]*N
block=[0]*N
size=[1]*N
def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x]
 
#同じ集合か判定
def same(x,y):
  return find(x)==find(y)
 
def union(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return 
  if rank[x]>rank[y]:
    par[y]=x
    size[x]+=size[y]
  else:
    par[x]=y
    size[y]+=size[x]
    if rank[x]==rank[y]:
      rank[y]+=1
E=[[]for i in range(N)] 
for d,s,t in D:
  s-=1
  t-=1
  union(s,t)
  E[s].append(t)
  E[t].append(s)
  if same(0,N-1):
    answ=d
    break
from collections import deque
d=deque()
d.append((0,0,0))
while d:
  now,pre,num=d.popleft()
  for nex in E[now]:
    if nex==N-1:
      print(answ,num+1)
      exit()
    if nex!=pre:
      d.append((nex,now,num+1))
0