結果

問題 No.488 四角関係
コンテスト
ユーザー daku9640
提出日時 2018-08-30 22:10:08
言語 Python3
(3.15.2 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 428 ms / 5,000 ms
+ 524µs
コード長 542 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 14,848 KB
実行使用メモリ 34,504 KB
最終ジャッジ日時 2026-11-05 23:55:47
合計ジャッジ時間 3,964 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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