結果

問題 No.488 四角関係
ユーザー daku9640daku9640
提出日時 2018-08-30 22:43:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 662 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 10,756 KB
実行使用メモリ 8,680 KB
最終ジャッジ日時 2023-10-11 21:46:17
合計ジャッジ時間 1,800 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 22 ms
8,564 KB
testcase_09 AC 19 ms
8,612 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 18 ms
8,372 KB
testcase_16 WA -
testcase_17 AC 19 ms
8,476 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 19 ms
8,512 KB
testcase_22 AC 20 ms
8,488 KB
testcase_23 AC 19 ms
8,448 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            if j in node[i]:
                continue
            sn = node[i] & node[j] - {i, j}
            if len(sn) < 2:
                continue
            for a, b in combinations(tuple(sn), 2):
                if a not in node[b]:
                    ans += 1
    return ans
print(solve())
0