結果

問題 No.488 四角関係
ユーザー cympfhcympfh
提出日時 2017-02-25 23:37:21
言語 Ruby
(3.3.0)
結果
AC  
実行時間 2,302 ms / 5,000 ms
コード長 462 bytes
コンパイル時間 535 ms
コンパイル使用メモリ 11,456 KB
実行使用メモリ 15,460 KB
最終ジャッジ日時 2023-09-02 08:19:35
合計ジャッジ時間 8,815 ms
ジャッジサーバーID
(参考情報)
judge16 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 302 ms
15,308 KB
testcase_01 AC 293 ms
15,396 KB
testcase_02 AC 319 ms
15,340 KB
testcase_03 AC 161 ms
15,460 KB
testcase_04 AC 218 ms
15,388 KB
testcase_05 AC 443 ms
15,148 KB
testcase_06 AC 544 ms
15,392 KB
testcase_07 AC 952 ms
15,236 KB
testcase_08 AC 2,302 ms
15,448 KB
testcase_09 AC 82 ms
15,124 KB
testcase_10 AC 135 ms
15,264 KB
testcase_11 AC 85 ms
15,128 KB
testcase_12 AC 115 ms
15,236 KB
testcase_13 AC 125 ms
15,404 KB
testcase_14 AC 89 ms
15,144 KB
testcase_15 AC 81 ms
15,128 KB
testcase_16 AC 80 ms
15,144 KB
testcase_17 AC 80 ms
15,092 KB
testcase_18 AC 81 ms
15,048 KB
testcase_19 AC 85 ms
15,272 KB
testcase_20 AC 82 ms
15,092 KB
testcase_21 AC 82 ms
15,228 KB
testcase_22 AC 80 ms
15,288 KB
testcase_23 AC 79 ms
15,272 KB
testcase_24 AC 81 ms
15,264 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,m = gets.chomp.split.map(&:to_i)
e=(0...n).map{|x| [x, []]}.to_h
m.times.map {
  u,v=gets.split.map(&:to_i)
  e[u] << v
  e[v] << u
}
ans=0
(0...n).to_a.combination(4) {|xs|
  u = xs[0]
  rest = xs[1..-1]
  rest.permutation(3) { |ys|
    next unless e[u].index ys[0]
    next unless e[ys[0]].index ys[1]
    next unless e[ys[1]].index ys[2]
    next unless e[ys[2]].index u
    next if e[u].index ys[1]
    next if e[ys[0]].index ys[2]
    ans+=1
  }
}
p ans/2
0