結果

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

ソースコード

diff #

from collections import defaultdict
from itertools import combinations
def solve():
    n, m = map(int, input().split())
    node = defaultdict(set)
    for _ in range(m):
        a, b = map(int, input().split())
        node[a].add(b)
        node[b].add(a)
    ans = set()
    for i in range(n - 1):
        for j in range(i + 1, n):
            if j in node[i]:
                continue
            sn = node[i] & node[j]
            for a, b in combinations(tuple(sn), 2):
                if a not in node[b]:
                    ans.add(frozenset([i, j, a, b]))
    return len(ans)
print(solve())
0