結果

問題 No.488 四角関係
ユーザー daku9640daku9640
提出日時 2018-08-30 23:02:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 59 ms / 5,000 ms
コード長 608 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 10,440 KB
最終ジャッジ日時 2023-10-11 21:47:02
合計ジャッジ時間 1,752 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,560 KB
testcase_01 AC 35 ms
9,124 KB
testcase_02 AC 25 ms
8,848 KB
testcase_03 AC 21 ms
8,704 KB
testcase_04 AC 24 ms
8,740 KB
testcase_05 AC 33 ms
9,144 KB
testcase_06 AC 20 ms
8,660 KB
testcase_07 AC 59 ms
10,440 KB
testcase_08 AC 26 ms
8,716 KB
testcase_09 AC 19 ms
8,464 KB
testcase_10 AC 21 ms
8,524 KB
testcase_11 AC 19 ms
8,392 KB
testcase_12 AC 22 ms
8,672 KB
testcase_13 AC 20 ms
8,724 KB
testcase_14 AC 19 ms
8,564 KB
testcase_15 AC 19 ms
8,668 KB
testcase_16 AC 18 ms
8,612 KB
testcase_17 AC 18 ms
8,528 KB
testcase_18 AC 19 ms
8,480 KB
testcase_19 AC 18 ms
8,628 KB
testcase_20 AC 18 ms
8,548 KB
testcase_21 AC 19 ms
8,620 KB
testcase_22 AC 18 ms
8,512 KB
testcase_23 AC 18 ms
8,464 KB
testcase_24 AC 19 ms
8,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from itertools import combinations
def solve():
    n, m = map(int, input().split())
    if n < 4:
        return 0
    node = defaultdict(set)
    for _ in range(m):
        a, b = map(int, input().split())
        node[a].add(b)
        node[b].add(a)
    ans = set()
    for k, v in node.items():
        for a, b in combinations(tuple(v), 2):
            if a in node[b]:
                continue
            for c in node[a] & node[b] - {k}:
                if k not in node[c]:
                    ans.add(frozenset([a, b, c, k]))
    return len(ans)
print(solve())
0