結果

問題 No.488 四角関係
ユーザー daku9640daku9640
提出日時 2018-08-31 21:37:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 931 ms / 5,000 ms
コード長 697 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 29,740 KB
最終ジャッジ日時 2023-10-11 22:57:29
合計ジャッジ時間 9,911 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 517 ms
29,548 KB
testcase_01 AC 362 ms
29,524 KB
testcase_02 AC 484 ms
29,588 KB
testcase_03 AC 247 ms
29,668 KB
testcase_04 AC 319 ms
29,572 KB
testcase_05 AC 568 ms
29,584 KB
testcase_06 AC 918 ms
29,444 KB
testcase_07 AC 928 ms
29,500 KB
testcase_08 AC 931 ms
29,544 KB
testcase_09 AC 135 ms
29,640 KB
testcase_10 AC 205 ms
29,652 KB
testcase_11 AC 139 ms
29,684 KB
testcase_12 AC 167 ms
29,524 KB
testcase_13 AC 197 ms
29,528 KB
testcase_14 AC 145 ms
29,548 KB
testcase_15 AC 136 ms
29,560 KB
testcase_16 AC 134 ms
29,556 KB
testcase_17 AC 136 ms
29,568 KB
testcase_18 AC 133 ms
29,540 KB
testcase_19 AC 136 ms
29,740 KB
testcase_20 AC 135 ms
29,540 KB
testcase_21 AC 135 ms
29,624 KB
testcase_22 AC 136 ms
29,668 KB
testcase_23 AC 138 ms
29,548 KB
testcase_24 AC 138 ms
29,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations
from sys import stdin, stdout
import numpy as np

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 = np.zeros((N, 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