結果

問題 No.762 PDCAパス
ユーザー maspymaspy
提出日時 2020-02-02 14:31:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 501 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 34,916 KB
最終ジャッジ日時 2023-10-19 00:49:58
合計ジャッジ時間 8,746 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,188 KB
testcase_01 AC 28 ms
10,188 KB
testcase_02 AC 29 ms
10,188 KB
testcase_03 AC 28 ms
10,188 KB
testcase_04 AC 29 ms
10,188 KB
testcase_05 AC 29 ms
10,188 KB
testcase_06 AC 29 ms
10,188 KB
testcase_07 AC 29 ms
10,188 KB
testcase_08 AC 28 ms
10,188 KB
testcase_09 AC 28 ms
10,188 KB
testcase_10 AC 29 ms
10,188 KB
testcase_11 AC 29 ms
10,188 KB
testcase_12 AC 29 ms
10,188 KB
testcase_13 AC 28 ms
10,188 KB
testcase_14 AC 29 ms
10,188 KB
testcase_15 AC 28 ms
10,188 KB
testcase_16 AC 29 ms
10,188 KB
testcase_17 AC 29 ms
10,188 KB
testcase_18 AC 28 ms
10,188 KB
testcase_19 AC 29 ms
10,188 KB
testcase_20 AC 29 ms
10,188 KB
testcase_21 AC 30 ms
10,188 KB
testcase_22 AC 259 ms
30,960 KB
testcase_23 AC 258 ms
30,960 KB
testcase_24 AC 238 ms
28,544 KB
testcase_25 AC 235 ms
28,544 KB
testcase_26 AC 265 ms
32,288 KB
testcase_27 AC 271 ms
32,316 KB
testcase_28 AC 321 ms
34,916 KB
testcase_29 AC 304 ms
34,916 KB
testcase_30 AC 302 ms
34,728 KB
testcase_31 AC 299 ms
34,728 KB
testcase_32 AC 300 ms
34,728 KB
testcase_33 AC 297 ms
34,356 KB
testcase_34 AC 300 ms
34,356 KB
testcase_35 AC 305 ms
34,356 KB
testcase_36 AC 281 ms
34,608 KB
testcase_37 AC 273 ms
34,608 KB
testcase_38 AC 275 ms
34,608 KB
testcase_39 AC 276 ms
34,608 KB
testcase_40 AC 275 ms
34,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

N,M = map(int,readline().split())
words = '$' + readline().decode().rstrip()
m = map(int,read().split())
UV = tuple(zip(m,m))

MOD = 10**9 + 7

UV += tuple((v,u) for u,v in UV)

dp = [1 * (s == 'P') for s in words] 

for T in 'DCA':
    newdp = [0] * (N+1)
    for u,v in UV:
        if words[v] == T:
            newdp[v] += dp[u]
    dp = newdp

answer = sum(dp) % MOD
print(answer)
0