結果

問題 No.488 四角関係
ユーザー daku9640daku9640
提出日時 2018-08-31 21:33:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,061 ms / 5,000 ms
コード長 577 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 10,744 KB
実行使用メモリ 29,688 KB
最終ジャッジ日時 2023-10-11 22:56:59
合計ジャッジ時間 7,460 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 291 ms
29,496 KB
testcase_01 AC 263 ms
29,492 KB
testcase_02 AC 290 ms
29,568 KB
testcase_03 AC 186 ms
29,688 KB
testcase_04 AC 222 ms
29,504 KB
testcase_05 AC 350 ms
29,576 KB
testcase_06 AC 450 ms
29,560 KB
testcase_07 AC 567 ms
29,604 KB
testcase_08 AC 1,061 ms
29,632 KB
testcase_09 AC 135 ms
29,540 KB
testcase_10 AC 167 ms
29,644 KB
testcase_11 AC 136 ms
29,652 KB
testcase_12 AC 154 ms
29,512 KB
testcase_13 AC 162 ms
29,572 KB
testcase_14 AC 137 ms
29,532 KB
testcase_15 AC 135 ms
29,520 KB
testcase_16 AC 132 ms
29,564 KB
testcase_17 AC 133 ms
29,584 KB
testcase_18 AC 135 ms
29,624 KB
testcase_19 AC 137 ms
29,508 KB
testcase_20 AC 137 ms
29,456 KB
testcase_21 AC 133 ms
29,516 KB
testcase_22 AC 134 ms
29,652 KB
testcase_23 AC 131 ms
29,508 KB
testcase_24 AC 134 ms
29,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
from itertools import combinations

n, m = tuple(int(x) for x in input().split())
mtx = np.zeros((n, n))

for _ in range(m):
    a, b = tuple(int(x) for x in input().split())
    mtx[a][b] = mtx[b][a] = True

def check_square(i, j, k, l):
    return mtx[i][j] and mtx[j][k] and mtx[k][l] and mtx[l][i] and not mtx[i][k] and not mtx[j][l]

cnt = 0

for i, j, k, l in combinations(range(n), 4):
    if check_square(i, j, k, l):
        cnt += 1
    elif check_square(i, k, j, l):
        cnt += 1
    elif check_square(i, j, l, k):
        cnt += 1

print(cnt)
0