結果

問題 No.488 四角関係
ユーザー GrayCoder
提出日時 2018-06-29 03:37:19
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 687 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 22,784 KB
最終ジャッジ日時 2024-06-30 23:42:43
合計ジャッジ時間 2,316 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 RE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations
from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
write = stdout.write

def main():
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * M]

    edge = [[0] * M for _ in [0] * M]
    for a, b in AB:
        edge[a][b] = edge[b][a] = 1

    square = 0
    for a, b, c, d in combinations(range(N), 4):
        if all((edge[a][b] + edge[a][c] + edge[a][d] == 2,
                edge[b][a] + edge[b][c] + edge[b][d] == 2,
                edge[c][a] + edge[c][b] + edge[c][d] == 2,
                edge[d][a] + edge[d][b] + edge[d][c] == 2)):
            square += 1
    print(square)

main()
0