結果

問題 No.488 四角関係
ユーザー ciel
提出日時 2017-02-27 11:54:41
言語 Ruby
(4.0.9 + ACL)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
AC  
実行時間 2,105 ms / 5,000 ms
+ 113µs
コード長 375 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 14 ms
コンパイル使用メモリ 9,792 KB
実行使用メモリ 14,592 KB
最終ジャッジ日時 2026-11-05 23:11:32
合計ジャッジ時間 10,815 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge7_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #
raw source code

#!/usr/bin/ruby
h=Hash.new{|h,k|h[k]=[]}
n,m=gets.split.map(&:to_i)
m.times{
	x,y=gets.split.map(&:to_i)
	h[x]<<y
	h[y]<<x
}
p [*0..n].combination(4).count{|a0|
	a0[0,3].permutation.any?{|a|
		a+=[a0[3]]
		h[a[0]].include?(a[1]) &&
		h[a[1]].include?(a[2]) &&
		h[a[2]].include?(a[3]) &&
		h[a[3]].include?(a[0]) &&
		!h[a[0]].include?(a[2]) &&
		!h[a[1]].include?(a[3])
	}
}
0