結果

問題 No.488 四角関係
コンテスト
ユーザー daku9640
提出日時 2018-08-31 21:33:01
言語 Python3
(3.15.2 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 1,154 ms / 5,000 ms
+ 635µs
コード長 577 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 56 ms
コンパイル使用メモリ 14,848 KB
実行使用メモリ 33,632 KB
最終ジャッジ日時 2026-11-05 23:56:22
合計ジャッジ時間 15,562 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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