結果

問題 No.488 四角関係
ユーザー daku9640daku9640
提出日時 2018-08-30 22:10:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 367 ms / 5,000 ms
コード長 542 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 10,080 KB
最終ジャッジ日時 2023-10-11 21:45:45
合計ジャッジ時間 3,317 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
8,196 KB
testcase_01 AC 122 ms
8,824 KB
testcase_02 AC 145 ms
8,380 KB
testcase_03 AC 59 ms
8,296 KB
testcase_04 AC 88 ms
8,388 KB
testcase_05 AC 190 ms
8,756 KB
testcase_06 AC 281 ms
8,200 KB
testcase_07 AC 367 ms
10,080 KB
testcase_08 AC 275 ms
8,188 KB
testcase_09 AC 16 ms
8,172 KB
testcase_10 AC 43 ms
8,172 KB
testcase_11 AC 17 ms
8,160 KB
testcase_12 AC 31 ms
8,300 KB
testcase_13 AC 39 ms
8,324 KB
testcase_14 AC 21 ms
8,164 KB
testcase_15 AC 16 ms
8,304 KB
testcase_16 AC 16 ms
8,108 KB
testcase_17 AC 16 ms
8,284 KB
testcase_18 AC 16 ms
8,124 KB
testcase_19 AC 16 ms
8,160 KB
testcase_20 AC 16 ms
8,140 KB
testcase_21 AC 16 ms
8,144 KB
testcase_22 AC 17 ms
8,156 KB
testcase_23 AC 16 ms
8,220 KB
testcase_24 AC 17 ms
8,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations
from itertools import combinations
def solve():
    n, m = map(int, input().split())
    if n < 4:
        return 0
    node = [[0] * n for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        node[a][b] = node[b][a] = 1
    ans = set()
    for a, b, c, d in combinations(range(n), 4):
        if all(node[w][x] + node[w][y] + node[w][z] == 2 for w, x, y, z in permutations((a, b, c, d), 4)):
            ans.add(frozenset([a, b, c, d]))
    return len(ans)
print(solve())
0