結果

問題 No.488 四角関係
ユーザー daku9640daku9640
提出日時 2018-08-30 21:56:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 962 ms / 5,000 ms
コード長 508 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 10,040 KB
最終ジャッジ日時 2023-10-11 21:45:42
合計ジャッジ時間 5,432 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 313 ms
8,272 KB
testcase_01 AC 183 ms
8,860 KB
testcase_02 AC 266 ms
8,432 KB
testcase_03 AC 94 ms
8,320 KB
testcase_04 AC 144 ms
8,516 KB
testcase_05 AC 316 ms
8,768 KB
testcase_06 AC 639 ms
8,240 KB
testcase_07 AC 593 ms
10,040 KB
testcase_08 AC 962 ms
8,104 KB
testcase_09 AC 16 ms
8,148 KB
testcase_10 AC 67 ms
8,340 KB
testcase_11 AC 18 ms
8,288 KB
testcase_12 AC 41 ms
8,428 KB
testcase_13 AC 59 ms
8,200 KB
testcase_14 AC 23 ms
8,256 KB
testcase_15 AC 19 ms
8,112 KB
testcase_16 AC 16 ms
8,260 KB
testcase_17 AC 16 ms
8,264 KB
testcase_18 AC 16 ms
8,228 KB
testcase_19 AC 16 ms
8,140 KB
testcase_20 AC 16 ms
8,132 KB
testcase_21 AC 16 ms
8,168 KB
testcase_22 AC 16 ms
8,216 KB
testcase_23 AC 16 ms
8,080 KB
testcase_24 AC 16 ms
8,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations
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
    ans = set()
    for a, b, c, d in permutations(range(n), 4):
        if (node[a][b] == node[b][c] == node[c][d] == node[d][a] == 1) and (node[a][c] == node[b][d] == 0):
            ans.add(frozenset([a, b, c, d]))
    return len(ans)
print(solve())
0