提出 #314543
ソースコード 拡げる
def u_parent(uft,i)
if uft[i] != i
uft[i] = u_parent(uft,uft[i])
else
i
end
end
def union(uft,a,b)
ap = u_parent(uft,a)
uft[ap] = u_parent(uft,b)
end
N,M = gets.split.map(&:to_i)
uft = Array.new(N) {|i|
i
}
M.times {
a,b = gets.split.map(&:to_i)
a-=1
b-=1
union(uft,a,b)
}
puts (0..N-1).to_a.map {|a|
u_parent(uft,a)
}.uniq.length - 1
提出情報
コンパイルエラー
./Main.rb:27: warning: (...) interpreted as grouped expression
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 100 / 100 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample1.txt, sample2.txt |
| All | 0.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 0.txt | AC | 58 ms | 4200 KiB |
| 1.txt | AC | 59 ms | 4200 KiB |
| 10.txt | AC | 59 ms | 4200 KiB |
| 11.txt | AC | 61 ms | 4204 KiB |
| 12.txt | AC | 61 ms | 4204 KiB |
| 13.txt | AC | 62 ms | 4204 KiB |
| 14.txt | AC | 60 ms | 4204 KiB |
| 15.txt | AC | 397 ms | 4184 KiB |
| 16.txt | AC | 198 ms | 13676 KiB |
| 17.txt | AC | 209 ms | 13676 KiB |
| 18.txt | AC | 201 ms | 13768 KiB |
| 19.txt | AC | 586 ms | 7608 KiB |
| 2.txt | AC | 62 ms | 4204 KiB |
| 3.txt | AC | 60 ms | 4200 KiB |
| 4.txt | AC | 60 ms | 4204 KiB |
| 5.txt | AC | 61 ms | 4200 KiB |
| 6.txt | AC | 58 ms | 4204 KiB |
| 7.txt | AC | 57 ms | 4204 KiB |
| 8.txt | AC | 58 ms | 4200 KiB |
| 9.txt | AC | 60 ms | 4200 KiB |
| sample1.txt | AC | 59 ms | 4200 KiB |
| sample2.txt | AC | 57 ms | 4200 KiB |