結果

問題 No.488 四角関係
ユーザー neko_the_shadowneko_the_shadow
提出日時 2017-03-20 23:59:35
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 867 ms / 5,000 ms
コード長 468 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 10,836 KB
実行使用メモリ 8,288 KB
最終ジャッジ日時 2023-09-18 13:25:01
合計ジャッジ時間 6,363 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 414 ms
8,144 KB
testcase_01 AC 256 ms
8,252 KB
testcase_02 AC 379 ms
8,200 KB
testcase_03 AC 130 ms
8,096 KB
testcase_04 AC 207 ms
8,232 KB
testcase_05 AC 463 ms
8,084 KB
testcase_06 AC 836 ms
8,288 KB
testcase_07 AC 846 ms
8,104 KB
testcase_08 AC 867 ms
8,268 KB
testcase_09 AC 16 ms
8,184 KB
testcase_10 AC 90 ms
8,232 KB
testcase_11 AC 18 ms
8,240 KB
testcase_12 AC 49 ms
8,076 KB
testcase_13 AC 81 ms
8,228 KB
testcase_14 AC 28 ms
8,104 KB
testcase_15 AC 19 ms
8,188 KB
testcase_16 AC 17 ms
8,064 KB
testcase_17 AC 16 ms
8,204 KB
testcase_18 AC 17 ms
8,184 KB
testcase_19 AC 17 ms
8,220 KB
testcase_20 AC 17 ms
8,092 KB
testcase_21 AC 16 ms
8,204 KB
testcase_22 AC 16 ms
8,092 KB
testcase_23 AC 16 ms
8,212 KB
testcase_24 AC 17 ms
8,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

if __name__ == '__main__':
    n, m = map(int, input().split())

    matrix = [[0 for _ in range(n)] for _ in range(n)]
    for _ in range(m):
        x, y = map(int, input().split())
        matrix[x][y] = matrix[y][x] = 1

    cnt = 0
    for points in itertools.combinations(range(n), 4):
        totals = [sum(matrix[start][other] for other in points) for start in points]
        if all(total == 2 for total in totals): cnt += 1

    print(cnt)
0