結果

問題 No.1473 おでぶなおばけさん
ユーザー 👑 timitimi
提出日時 2021-04-26 17:04:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,033 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 131,828 KB
最終ジャッジ日時 2023-09-18 11:37:56
合計ジャッジ時間 34,618 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,620 KB
testcase_01 AC 96 ms
71,872 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 966 ms
131,308 KB
testcase_08 AC 944 ms
131,208 KB
testcase_09 AC 920 ms
130,044 KB
testcase_10 AC 445 ms
92,836 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 309 ms
87,072 KB
testcase_14 AC 254 ms
85,588 KB
testcase_15 AC 395 ms
91,656 KB
testcase_16 AC 422 ms
91,284 KB
testcase_17 AC 138 ms
78,348 KB
testcase_18 AC 151 ms
78,240 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 911 ms
130,440 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 TLE -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 TLE -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 426 ms
91,232 KB
testcase_42 AC 426 ms
91,432 KB
testcase_43 AC 293 ms
105,656 KB
testcase_44 AC 292 ms
105,776 KB
testcase_45 AC 293 ms
105,700 KB
testcase_46 AC 815 ms
112,796 KB
testcase_47 AC 864 ms
119,624 KB
testcase_48 AC 796 ms
114,864 KB
権限があれば一括ダウンロードができます

ソースコード

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)] 
limit=0
for d,s,t in D:
  #print(s,t,d,limit)
  if limit>d:
    break
  s-=1
  t-=1
  union(s,t)
  E[s].append(t)
  E[t].append(s)
  if same(0,N-1):
    answ=d
    limit=d
from collections import deque
d=deque()
d.append((0,0,0))
F=[N]*N
while d:
  now,pre,num=d.popleft()
  for nex in E[now]:
    if nex==N-1:
      print(answ,num+1)
      exit()
    if nex!=pre:
      if num+1<F[nex]:
        F[nex]=num
        d.appendleft((nex,now,num+1))
0