結果

問題 No.488 四角関係
ユーザー daku9640
提出日時 2018-08-30 22:10:51
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 419 ms / 5,000 ms
コード長 509 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-09-13 20:35:56
合計ジャッジ時間 3,667 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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
    num = 0
    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)):
            num += 1
    return num
print(solve())
0