結果

問題 No.488 四角関係
ユーザー wotsushiwotsushi
提出日時 2017-03-03 22:10:14
言語 Ruby
(3.3.0)
結果
AC  
実行時間 3,509 ms / 5,000 ms
コード長 388 bytes
コンパイル時間 42 ms
コンパイル使用メモリ 11,636 KB
実行使用メモリ 16,100 KB
最終ジャッジ日時 2023-09-04 05:56:33
合計ジャッジ時間 17,309 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 992 ms
15,852 KB
testcase_01 AC 804 ms
16,036 KB
testcase_02 AC 1,019 ms
15,904 KB
testcase_03 AC 409 ms
15,792 KB
testcase_04 AC 615 ms
15,836 KB
testcase_05 AC 1,360 ms
16,100 KB
testcase_06 AC 1,900 ms
15,924 KB
testcase_07 AC 2,637 ms
15,848 KB
testcase_08 AC 3,509 ms
15,928 KB
testcase_09 AC 80 ms
15,260 KB
testcase_10 AC 283 ms
15,784 KB
testcase_11 AC 89 ms
15,764 KB
testcase_12 AC 193 ms
15,832 KB
testcase_13 AC 259 ms
15,856 KB
testcase_14 AC 119 ms
15,996 KB
testcase_15 AC 86 ms
15,676 KB
testcase_16 AC 80 ms
15,152 KB
testcase_17 AC 78 ms
15,108 KB
testcase_18 AC 81 ms
15,248 KB
testcase_19 AC 83 ms
15,296 KB
testcase_20 AC 80 ms
15,344 KB
testcase_21 AC 79 ms
15,308 KB
testcase_22 AC 80 ms
15,232 KB
testcase_23 AC 80 ms
15,156 KB
testcase_24 AC 81 ms
15,180 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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