結果

問題 No.488 四角関係
ユーザー maspymaspy
提出日時 2023-07-22 16:41:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 674 ms / 5,000 ms
コード長 711 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 12,020 KB
実行使用メモリ 71,632 KB
最終ジャッジ日時 2023-10-23 23:08:55
合計ジャッジ時間 15,033 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 551 ms
56,908 KB
testcase_01 AC 521 ms
51,164 KB
testcase_02 AC 549 ms
55,388 KB
testcase_03 AC 508 ms
45,092 KB
testcase_04 AC 516 ms
47,468 KB
testcase_05 AC 577 ms
58,224 KB
testcase_06 AC 674 ms
71,632 KB
testcase_07 AC 657 ms
71,632 KB
testcase_08 AC 654 ms
71,632 KB
testcase_09 AC 472 ms
42,380 KB
testcase_10 AC 488 ms
44,032 KB
testcase_11 AC 473 ms
42,380 KB
testcase_12 AC 481 ms
42,424 KB
testcase_13 AC 494 ms
43,768 KB
testcase_14 AC 482 ms
42,380 KB
testcase_15 AC 486 ms
42,380 KB
testcase_16 AC 478 ms
42,380 KB
testcase_17 AC 476 ms
42,380 KB
testcase_18 AC 481 ms
42,380 KB
testcase_19 AC 476 ms
42,380 KB
testcase_20 AC 482 ms
42,380 KB
testcase_21 AC 479 ms
42,380 KB
testcase_22 AC 476 ms
42,380 KB
testcase_23 AC 477 ms
42,380 KB
testcase_24 AC 485 ms
42,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
import itertools

N,M = map(int,readline().split())
m = map(int,read().split())
AB = zip(m,m)

G = np.zeros((N,N),np.bool_)
for a,b in AB:
    G[a,b] = 1
    G[b,a] = 1

ABCD = np.array(list(itertools.combinations(range(N),4)))

if ABCD.shape[0] == 0:
    print(0)
    exit()

def deg(i):
    d = np.zeros(ABCD.shape[0],np.int32)
    for j in range(4):
        if i == j:
            continue
        d += G[ABCD[:,i], ABCD[:,j]]
    return d

is_ok = np.ones(ABCD.shape[0],np.bool_)
for i in range(4):
    is_ok &= deg(i) == 2

answer = np.count_nonzero(is_ok)
print(answer)
0