
エントリーの編集

エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
Ruby で解く AtCoder ABC177 D UnionFind - Qiita
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています

- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
Ruby で解く AtCoder ABC177 D UnionFind - Qiita
はじめに AtCoder Problems の Recommendation を利用して、過去の問題を解いています。 AtCoder さん、... はじめに AtCoder Problems の Recommendation を利用して、過去の問題を解いています。 AtCoder さん、AtCoder Problems さん、ありがとうございます。 今回のお題 AtCoder Beginner Contest D - Friends Difficulty: 676 今回のテーマ、UnionFind 典型問題の B - Union Find - AtCoder の応用です。 Ruby class UnionFind def initialize(n) @parents = Array.new(n, -1) end def find(x) @parents[x] < 0 ? x : @parents[x] = find(@parents[x]) end def parents @parents end def union(x, y) x