結果

問題 No.329 全射
ユーザー maspymaspy
提出日時 2020-04-03 02:11:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 856 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 40,900 KB
最終ジャッジ日時 2023-09-11 02:39:40
合計ジャッジ時間 13,583 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 172 ms
37,632 KB
testcase_01 AC 174 ms
37,592 KB
testcase_02 AC 172 ms
37,584 KB
testcase_03 AC 173 ms
37,608 KB
testcase_04 AC 172 ms
37,668 KB
testcase_05 AC 176 ms
37,712 KB
testcase_06 AC 175 ms
37,668 KB
testcase_07 AC 174 ms
37,700 KB
testcase_08 AC 174 ms
37,748 KB
testcase_09 AC 175 ms
37,476 KB
testcase_10 AC 173 ms
37,464 KB
testcase_11 AC 172 ms
37,524 KB
testcase_12 AC 172 ms
37,724 KB
testcase_13 AC 395 ms
40,608 KB
testcase_14 WA -
testcase_15 AC 308 ms
40,236 KB
testcase_16 AC 319 ms
40,132 KB
testcase_17 AC 351 ms
40,520 KB
testcase_18 AC 362 ms
40,492 KB
testcase_19 AC 404 ms
40,692 KB
testcase_20 AC 371 ms
40,604 KB
testcase_21 AC 347 ms
40,124 KB
testcase_22 WA -
testcase_23 AC 236 ms
39,636 KB
testcase_24 AC 235 ms
39,580 KB
testcase_25 AC 292 ms
40,108 KB
testcase_26 AC 250 ms
39,200 KB
testcase_27 WA -
testcase_28 AC 171 ms
37,648 KB
testcase_29 AC 184 ms
37,976 KB
testcase_30 AC 175 ms
37,920 KB
testcase_31 AC 171 ms
37,560 KB
testcase_32 AC 184 ms
37,976 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 10 ** 9 + 7

N, M = map(int, readline().split())
W = np.array(readline().split(), np.int64)
IJ = np.array(read().split(), np.int32) - 1
I = IJ[::2]
J = IJ[1::2]

A = np.zeros((N, N), np.int32)
np.fill_diagonal(A, W)
A[I, J] = np.minimum(W[I], W[J])

for i in range(N):
    for j in range(N):
        A[i, j] = np.max(np.minimum(A[i, :], A[:, j]))


# 全射の数え上げ
U = 1000
dp = np.zeros((U + 1, U + 1), np.int64)
dp[0, 0] = 1
for n in range(U):
    dp[n + 1] += np.arange(U + 1, dtype=np.int64) * dp[n]
    dp[n + 1, 1:] += np.arange(1, U + 1, dtype=np.int64) * dp[n, :-1]
    dp[n + 1] %= MOD

reachable = A == W[None, :]
answer = (dp[W][:, W] * reachable).sum() % MOD
print(answer)
0