結果

問題 No.488 四角関係
ユーザー wotsushi
提出日時 2017-03-03 22:10:14
言語 Ruby
(3.4.1)
結果
AC  
実行時間 3,711 ms / 5,000 ms
コード長 388 bytes
コンパイル時間 63 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-06-22 05:20:10
合計ジャッジ時間 17,776 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map(&:to_i)
a, b = (1..M).map {gets.split.map(&:to_i)}.transpose
g = Array.new(N) {|i| Array.new(N) {|j| a.zip(b).any? {|x, y| [x, y] == [i, j].sort}}}
ans = if N <= 3
        0
      else
        (0...N).to_a.combination(4).count {|arr| arr.permutation.any? {|x, y, z, w| g[x][y] and g[y][z] and g[z][w] and g[w][x] and not g[x][z] and not g[y][w]}}
      end
puts ans
0