結果

問題 No.488 四角関係
ユーザー ciel
提出日時 2017-02-27 11:54:41
言語 Ruby
(3.4.1)
結果
AC  
実行時間 2,549 ms / 5,000 ms
コード長 375 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-06-11 19:20:25
合計ジャッジ時間 9,967 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/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