結果

問題 No.329 全射
ユーザー TawaraTawara
提出日時 2015-12-24 21:29:43
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 852 bytes
コンパイル時間 1,095 ms
コンパイル使用メモリ 77,520 KB
実行使用メモリ 96,848 KB
最終ジャッジ日時 2023-10-19 02:55:18
合計ジャッジ時間 12,020 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
76,128 KB
testcase_01 AC 76 ms
76,128 KB
testcase_02 AC 76 ms
76,128 KB
testcase_03 AC 74 ms
76,128 KB
testcase_04 WA -
testcase_05 AC 75 ms
76,128 KB
testcase_06 WA -
testcase_07 AC 75 ms
76,128 KB
testcase_08 AC 76 ms
76,128 KB
testcase_09 AC 76 ms
76,128 KB
testcase_10 AC 76 ms
76,128 KB
testcase_11 AC 75 ms
76,128 KB
testcase_12 AC 76 ms
76,128 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 88 ms
79,672 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 122 ms
81,032 KB
testcase_40 WA -
testcase_41 AC 125 ms
81,084 KB
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(1000000)
p = 10**9+7
N,M = map(int,raw_input().split())
w = map(int,raw_input().split())
w_max = max(w)
C = [[0]*(i+1) for i in xrange(w_max+1)]
C[0][0] = 1
for i in xrange(w_max):
	for j in xrange(i+1):
		C[i][j] %= p
		C[i+1][j] += C[i][j]
		C[i+1][j+1] += C[i][j]
for i in xrange(w_max+1): C[w_max][i] %= p
E = [[] for i in xrange(N)]
for t in xrange(M):
	i,j = map(lambda x:int(x)-1,raw_input().split())
	E[i].append(j)
proj = set()
visited = set()
def dfs(s,h,w_min):
	if h in visited: return
	visited.add(h)
	if w[s] >= w[h] and w[h] <= w_min:
		proj.add((s,h))
	w_min = min(w_min,w[h])
	for nxt in E[h]:
		dfs(s,nxt,w_min)
for i in xrange(N):
	visited = set()
	dfs(i,i,w[i])
ans = 0
for i,j in proj:
	wi = w[i]; wj = w[j]
	ans += sum(C[wj][k]*pow(wj-k,wi,p)*((-1)**(k%2)) for k in xrange(wj))
	ans %= p
print ans
0