結果

問題 No.1473 おでぶなおばけさん
ユーザー 👑 timitimi
提出日時 2021-04-26 16:07:43
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,042 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 86,588 KB
実行使用メモリ 549,224 KB
最終ジャッジ日時 2023-09-18 09:06:50
合計ジャッジ時間 30,598 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
75,960 KB
testcase_01 AC 99 ms
71,320 KB
testcase_02 AC 969 ms
123,888 KB
testcase_03 AC 753 ms
117,856 KB
testcase_04 AC 561 ms
103,436 KB
testcase_05 AC 326 ms
84,816 KB
testcase_06 AC 785 ms
117,592 KB
testcase_07 AC 967 ms
129,796 KB
testcase_08 AC 983 ms
128,932 KB
testcase_09 AC 946 ms
131,932 KB
testcase_10 AC 410 ms
91,192 KB
testcase_11 AC 418 ms
92,256 KB
testcase_12 AC 403 ms
90,976 KB
testcase_13 AC 288 ms
86,288 KB
testcase_14 AC 243 ms
85,720 KB
testcase_15 AC 382 ms
93,396 KB
testcase_16 AC 393 ms
91,064 KB
testcase_17 AC 126 ms
78,836 KB
testcase_18 AC 136 ms
79,968 KB
testcase_19 AC 461 ms
91,300 KB
testcase_20 AC 744 ms
113,688 KB
testcase_21 AC 678 ms
103,972 KB
testcase_22 AC 787 ms
115,640 KB
testcase_23 AC 771 ms
111,400 KB
testcase_24 AC 771 ms
111,100 KB
testcase_25 AC 892 ms
114,492 KB
testcase_26 AC 908 ms
113,520 KB
testcase_27 AC 363 ms
87,052 KB
testcase_28 AC 921 ms
128,352 KB
testcase_29 AC 576 ms
103,012 KB
testcase_30 AC 676 ms
106,284 KB
testcase_31 AC 765 ms
130,584 KB
testcase_32 AC 551 ms
121,228 KB
testcase_33 AC 523 ms
112,716 KB
testcase_34 AC 406 ms
97,536 KB
testcase_35 AC 362 ms
92,840 KB
testcase_36 AC 660 ms
125,976 KB
testcase_37 AC 660 ms
108,904 KB
testcase_38 AC 257 ms
82,260 KB
testcase_39 AC 401 ms
91,316 KB
testcase_40 AC 402 ms
91,272 KB
testcase_41 AC 397 ms
91,556 KB
testcase_42 AC 395 ms
91,644 KB
testcase_43 AC 260 ms
103,508 KB
testcase_44 AC 260 ms
103,812 KB
testcase_45 AC 262 ms
103,644 KB
testcase_46 MLE -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**7)
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))
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