結果

問題 No.1473 おでぶなおばけさん
ユーザー 👑 obakyanobakyan
提出日時 2021-05-24 16:15:28
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 345 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 5,424 KB
実行使用メモリ 26,068 KB
最終ジャッジ日時 2023-08-03 02:36:08
合計ジャッジ時間 11,783 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 345 ms
25,092 KB
testcase_03 AC 222 ms
21,500 KB
testcase_04 AC 148 ms
14,808 KB
testcase_05 AC 53 ms
7,244 KB
testcase_06 AC 271 ms
22,636 KB
testcase_07 AC 295 ms
25,548 KB
testcase_08 AC 304 ms
26,068 KB
testcase_09 AC 290 ms
25,480 KB
testcase_10 AC 206 ms
14,340 KB
testcase_11 AC 193 ms
14,304 KB
testcase_12 AC 193 ms
14,328 KB
testcase_13 AC 117 ms
10,632 KB
testcase_14 AC 80 ms
7,956 KB
testcase_15 AC 172 ms
13,540 KB
testcase_16 AC 193 ms
14,140 KB
testcase_17 AC 12 ms
4,380 KB
testcase_18 AC 20 ms
4,380 KB
testcase_19 AC 149 ms
13,064 KB
testcase_20 AC 189 ms
19,904 KB
testcase_21 AC 216 ms
17,456 KB
testcase_22 AC 227 ms
23,200 KB
testcase_23 AC 181 ms
21,056 KB
testcase_24 AC 194 ms
18,972 KB
testcase_25 AC 221 ms
22,856 KB
testcase_26 AC 232 ms
21,676 KB
testcase_27 AC 97 ms
10,024 KB
testcase_28 AC 289 ms
25,220 KB
testcase_29 AC 172 ms
17,304 KB
testcase_30 AC 211 ms
19,376 KB
testcase_31 AC 297 ms
25,548 KB
testcase_32 AC 234 ms
22,664 KB
testcase_33 AC 196 ms
18,488 KB
testcase_34 AC 111 ms
11,044 KB
testcase_35 AC 121 ms
11,312 KB
testcase_36 AC 178 ms
16,300 KB
testcase_37 AC 170 ms
20,204 KB
testcase_38 AC 35 ms
5,620 KB
testcase_39 AC 213 ms
14,308 KB
testcase_40 AC 203 ms
14,332 KB
testcase_41 AC 198 ms
14,176 KB
testcase_42 AC 197 ms
14,272 KB
testcase_43 AC 202 ms
20,304 KB
testcase_44 AC 194 ms
20,392 KB
testcase_45 AC 197 ms
20,388 KB
testcase_46 AC 205 ms
18,520 KB
testcase_47 AC 255 ms
23,432 KB
testcase_48 AC 225 ms
21,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=io.read("*n","*n") p= {} e={} l={} for i = 1,n do p[i]=i e[i]={} l[i]=-1 end l[1]=0
function F(i) j=i while p[i]~=i do i=p[i] end while p[j]~=i do p[j],j=i,p[j] end return i end
q={} for i=1,m do q[i]={io.read("*n","*n","*n")} end
table.sort(q,function(a,b) return a[3]>b[3] end) w=0
for i=1,m do a=q[i][1] b=q[i][2] c=q[i][3] if c<w then break end e[a][#e[a]+1]=b e[b][#e[b]+1]=a x=F(a) y=F(b) p[b]=x p[y]=x x=F(1) y=F(n) if x==y then w=c end end t={1} v=0
while v<#t do v=v+1 s=t[v] for i=1,#e[s] do d=e[s][i] if l[d]<0 then l[d]=l[s]+1 t[#t+1]=d end end end print(w .. " " .. l[n])
0