結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
37,636 KB
testcase_01 AC 169 ms
37,452 KB
testcase_02 AC 172 ms
37,544 KB
testcase_03 AC 172 ms
37,496 KB
testcase_04 AC 171 ms
37,548 KB
testcase_05 AC 172 ms
37,580 KB
testcase_06 AC 172 ms
37,536 KB
testcase_07 AC 174 ms
37,584 KB
testcase_08 AC 172 ms
37,640 KB
testcase_09 AC 171 ms
37,636 KB
testcase_10 AC 171 ms
37,464 KB
testcase_11 AC 172 ms
37,312 KB
testcase_12 AC 170 ms
37,480 KB
testcase_13 AC 412 ms
41,452 KB
testcase_14 WA -
testcase_15 AC 311 ms
40,412 KB
testcase_16 AC 318 ms
40,624 KB
testcase_17 AC 360 ms
40,880 KB
testcase_18 AC 384 ms
41,272 KB
testcase_19 AC 416 ms
41,628 KB
testcase_20 AC 387 ms
41,496 KB
testcase_21 AC 353 ms
40,572 KB
testcase_22 WA -
testcase_23 AC 236 ms
39,636 KB
testcase_24 AC 233 ms
39,448 KB
testcase_25 AC 300 ms
40,168 KB
testcase_26 AC 248 ms
39,252 KB
testcase_27 WA -
testcase_28 AC 173 ms
37,640 KB
testcase_29 AC 183 ms
38,012 KB
testcase_30 AC 180 ms
37,928 KB
testcase_31 AC 171 ms
37,520 KB
testcase_32 AC 186 ms
37,856 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.int64) - 1
I = IJ[::2]
J = IJ[1::2]

A = np.zeros((N, N), np.int64)
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