結果

問題 No.629 グラフの中に眠る門松列
ユーザー cielciel
提出日時 2018-01-08 22:27:17
言語 Ruby
(3.3.0)
結果
AC  
実行時間 94 ms / 4,000 ms
コード長 363 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 11,520 KB
実行使用メモリ 15,676 KB
最終ジャッジ日時 2023-08-25 00:48:16
合計ジャッジ時間 5,646 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,152 KB
testcase_01 AC 81 ms
15,132 KB
testcase_02 AC 83 ms
15,288 KB
testcase_03 AC 84 ms
15,156 KB
testcase_04 AC 84 ms
15,108 KB
testcase_05 AC 83 ms
15,336 KB
testcase_06 AC 84 ms
15,152 KB
testcase_07 AC 82 ms
15,080 KB
testcase_08 AC 83 ms
15,132 KB
testcase_09 AC 83 ms
15,120 KB
testcase_10 AC 83 ms
15,180 KB
testcase_11 AC 83 ms
15,080 KB
testcase_12 AC 84 ms
15,152 KB
testcase_13 AC 86 ms
15,260 KB
testcase_14 AC 83 ms
15,340 KB
testcase_15 AC 83 ms
15,152 KB
testcase_16 AC 83 ms
15,252 KB
testcase_17 AC 83 ms
15,296 KB
testcase_18 AC 82 ms
15,292 KB
testcase_19 AC 83 ms
15,364 KB
testcase_20 AC 82 ms
15,088 KB
testcase_21 AC 89 ms
15,372 KB
testcase_22 AC 85 ms
15,324 KB
testcase_23 AC 85 ms
15,320 KB
testcase_24 AC 90 ms
15,364 KB
testcase_25 AC 91 ms
15,332 KB
testcase_26 AC 91 ms
15,676 KB
testcase_27 AC 91 ms
15,432 KB
testcase_28 AC 87 ms
15,084 KB
testcase_29 AC 91 ms
15,520 KB
testcase_30 AC 94 ms
15,412 KB
testcase_31 AC 94 ms
15,572 KB
testcase_32 AC 91 ms
15,516 KB
testcase_33 AC 93 ms
15,560 KB
testcase_34 AC 88 ms
15,316 KB
testcase_35 AC 88 ms
15,356 KB
testcase_36 AC 93 ms
15,408 KB
testcase_37 AC 91 ms
15,516 KB
testcase_38 AC 93 ms
15,616 KB
testcase_39 AC 91 ms
15,404 KB
testcase_40 AC 90 ms
15,372 KB
testcase_41 AC 88 ms
15,368 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Main.rb:1: warning: assigned but unused variable - m
Syntax OK

ソースコード

diff #

(n,m),a,*q=$<.map{|e|e.split.map &:to_i}
h=Hash.new{|h,k|h[k]=[]}
q.each{|u,v|h[u-1]<<v-1;h[v-1]<<u-1}
puts h.any?{|k,v|
	h0=Hash.new 0
	h1=Hash.new 0
	v.each{|e|
		h0[a[e]]+=1 if a[k]<a[e]
		h1[a[e]]+=1 if a[k]>a[e]
	}
	[h0,h1].map{|g|
		x=g.values.reduce(0,:+)
		x=x*~-x/2
		g.each_value{|w|x-=w*~-w/2}
		x
	}.reduce(:+)>0 # 門松パスの個数
} ? :YES : :NO
0