結果

問題 No.488 四角関係
ユーザー GrayCoderGrayCoder
提出日時 2018-06-29 03:39:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 687 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 10,972 KB
実行使用メモリ 8,380 KB
最終ジャッジ日時 2023-09-13 15:04:47
合計ジャッジ時間 2,066 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
8,320 KB
testcase_01 AC 45 ms
8,240 KB
testcase_02 AC 60 ms
8,380 KB
testcase_03 AC 30 ms
8,224 KB
testcase_04 AC 39 ms
8,200 KB
testcase_05 AC 71 ms
8,292 KB
testcase_06 AC 113 ms
8,284 KB
testcase_07 AC 122 ms
8,224 KB
testcase_08 AC 113 ms
8,372 KB
testcase_09 AC 16 ms
8,280 KB
testcase_10 AC 24 ms
8,252 KB
testcase_11 AC 16 ms
8,224 KB
testcase_12 AC 19 ms
8,148 KB
testcase_13 AC 23 ms
8,276 KB
testcase_14 AC 18 ms
8,172 KB
testcase_15 AC 15 ms
8,208 KB
testcase_16 AC 15 ms
8,216 KB
testcase_17 AC 15 ms
8,272 KB
testcase_18 AC 15 ms
8,172 KB
testcase_19 AC 16 ms
8,208 KB
testcase_20 AC 15 ms
8,164 KB
testcase_21 AC 15 ms
8,160 KB
testcase_22 AC 16 ms
8,172 KB
testcase_23 AC 15 ms
8,176 KB
testcase_24 AC 15 ms
8,220 KB
権限があれば一括ダウンロードができます

ソースコード

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] * N for _ in [0] * N]
    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