結果

問題 No.1473 おでぶなおばけさん
ユーザー 👑 timitimi
提出日時 2021-04-26 16:03:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 977 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 11,080 KB
実行使用メモリ 73,884 KB
最終ジャッジ日時 2023-09-18 09:02:31
合計ジャッジ時間 30,403 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
13,052 KB
testcase_01 AC 19 ms
8,600 KB
testcase_02 AC 1,048 ms
45,768 KB
testcase_03 AC 828 ms
38,300 KB
testcase_04 AC 457 ms
27,984 KB
testcase_05 AC 151 ms
15,256 KB
testcase_06 AC 744 ms
38,892 KB
testcase_07 AC 938 ms
45,360 KB
testcase_08 AC 1,036 ms
45,548 KB
testcase_09 AC 926 ms
45,468 KB
testcase_10 AC 427 ms
22,788 KB
testcase_11 AC 437 ms
21,376 KB
testcase_12 AC 435 ms
23,248 KB
testcase_13 AC 272 ms
16,096 KB
testcase_14 AC 196 ms
13,984 KB
testcase_15 AC 376 ms
19,124 KB
testcase_16 AC 414 ms
22,308 KB
testcase_17 AC 44 ms
9,336 KB
testcase_18 AC 62 ms
9,804 KB
testcase_19 AC 379 ms
23,496 KB
testcase_20 AC 898 ms
35,600 KB
testcase_21 AC 645 ms
34,168 KB
testcase_22 AC 829 ms
39,872 KB
testcase_23 AC 872 ms
35,808 KB
testcase_24 AC 754 ms
36,648 KB
testcase_25 AC 840 ms
41,396 KB
testcase_26 AC 824 ms
40,036 KB
testcase_27 AC 339 ms
22,444 KB
testcase_28 AC 1,024 ms
44,612 KB
testcase_29 AC 534 ms
30,580 KB
testcase_30 AC 644 ms
33,840 KB
testcase_31 AC 948 ms
47,188 KB
testcase_32 AC 663 ms
39,928 KB
testcase_33 AC 590 ms
36,064 KB
testcase_34 AC 260 ms
22,128 KB
testcase_35 AC 271 ms
22,288 KB
testcase_36 AC 823 ms
48,424 KB
testcase_37 AC 610 ms
34,144 KB
testcase_38 AC 130 ms
13,492 KB
testcase_39 AC 427 ms
22,652 KB
testcase_40 AC 421 ms
22,644 KB
testcase_41 AC 399 ms
19,824 KB
testcase_42 AC 403 ms
19,972 KB
testcase_43 AC 448 ms
34,140 KB
testcase_44 AC 450 ms
34,036 KB
testcase_45 AC 451 ms
34,216 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)] 
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