結果

問題 No.488 四角関係
ユーザー daku9640daku9640
提出日時 2018-08-30 22:10:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 360 ms / 5,000 ms
コード長 509 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 8,316 KB
最終ジャッジ日時 2023-10-11 21:45:48
合計ジャッジ時間 3,313 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 146 ms
8,292 KB
testcase_01 AC 117 ms
8,304 KB
testcase_02 AC 144 ms
8,088 KB
testcase_03 AC 59 ms
8,116 KB
testcase_04 AC 88 ms
8,172 KB
testcase_05 AC 187 ms
8,104 KB
testcase_06 AC 287 ms
8,188 KB
testcase_07 AC 360 ms
8,264 KB
testcase_08 AC 275 ms
8,316 KB
testcase_09 AC 16 ms
8,104 KB
testcase_10 AC 44 ms
8,272 KB
testcase_11 AC 17 ms
8,132 KB
testcase_12 AC 32 ms
8,108 KB
testcase_13 AC 40 ms
8,280 KB
testcase_14 AC 21 ms
8,116 KB
testcase_15 AC 17 ms
8,108 KB
testcase_16 AC 16 ms
8,084 KB
testcase_17 AC 16 ms
8,160 KB
testcase_18 AC 17 ms
8,084 KB
testcase_19 AC 17 ms
8,140 KB
testcase_20 AC 16 ms
8,276 KB
testcase_21 AC 17 ms
8,088 KB
testcase_22 AC 16 ms
8,100 KB
testcase_23 AC 15 ms
8,144 KB
testcase_24 AC 17 ms
8,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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
    num = 0
    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)):
            num += 1
    return num
print(solve())
0