結果
問題 | No.1390 Get together |
ユーザー |
![]() |
提出日時 | 2021-02-12 22:06:15 |
言語 | Ruby (3.4.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 643 bytes |
コンパイル時間 | 191 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 41,728 KB |
最終ジャッジ日時 | 2024-07-19 21:47:23 |
合計ジャッジ時間 | 16,881 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 RE * 11 |
コンパイルメッセージ
Syntax OK
ソースコード
n,m=gets.split.map(&:to_i)lc=[]n.times dolc << []endn.times dob,c=gets.split.map(&:to_i).map{|x|x-1}lc[c] << bendl=[]m.times do |i|l << iendlc.each do |lcc|a=0lcc.uniq.each.with_index do |ll,i|if i==0a=llnextendb=lls=[a,b]k=awhile l[k]!=kk=l[k]s << kendk=bwhile l[k]!=kk=l[k]s << kendmin=s.mins.uniq.each do |t|l[t]=min if l[t]!=minendendendc=[0]*nm.times do |i|if l[i]!=i&&l[i]!=l[l[i]]l[i]=l[l[i]]endc[l[i]]+=1endans=mm.times do |i|if l[i]==ians-=1endendputs ans