結果

問題 No.762 PDCAパス
ユーザー tobusakanatobusakana
提出日時 2022-11-27 16:10:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 89,972 KB
最終ジャッジ日時 2024-04-14 23:42:07
合計ジャッジ時間 5,633 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,780 KB
testcase_01 AC 38 ms
53,972 KB
testcase_02 AC 38 ms
52,868 KB
testcase_03 AC 37 ms
52,524 KB
testcase_04 AC 37 ms
53,004 KB
testcase_05 AC 37 ms
52,008 KB
testcase_06 AC 37 ms
53,872 KB
testcase_07 AC 37 ms
52,948 KB
testcase_08 AC 37 ms
52,140 KB
testcase_09 AC 37 ms
53,692 KB
testcase_10 AC 37 ms
52,204 KB
testcase_11 AC 37 ms
53,200 KB
testcase_12 AC 38 ms
53,040 KB
testcase_13 AC 37 ms
52,092 KB
testcase_14 AC 38 ms
52,992 KB
testcase_15 AC 37 ms
52,820 KB
testcase_16 AC 37 ms
52,556 KB
testcase_17 AC 37 ms
52,408 KB
testcase_18 AC 38 ms
52,740 KB
testcase_19 AC 38 ms
52,884 KB
testcase_20 AC 38 ms
52,196 KB
testcase_21 AC 37 ms
52,544 KB
testcase_22 AC 81 ms
77,572 KB
testcase_23 AC 81 ms
77,756 KB
testcase_24 AC 150 ms
89,156 KB
testcase_25 AC 152 ms
89,204 KB
testcase_26 AC 86 ms
77,576 KB
testcase_27 AC 85 ms
77,700 KB
testcase_28 AC 178 ms
89,972 KB
testcase_29 AC 177 ms
89,880 KB
testcase_30 AC 173 ms
87,880 KB
testcase_31 AC 171 ms
87,520 KB
testcase_32 AC 168 ms
87,408 KB
testcase_33 AC 151 ms
83,664 KB
testcase_34 AC 148 ms
83,468 KB
testcase_35 AC 147 ms
83,664 KB
testcase_36 AC 123 ms
79,892 KB
testcase_37 AC 126 ms
79,588 KB
testcase_38 AC 122 ms
79,788 KB
testcase_39 AC 125 ms
79,508 KB
testcase_40 AC 126 ms
79,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
S = readline().rstrip()
DIV = 10 ** 9 + 7

G = [[] for i in range(N)]
for _ in range(M):
    u,v = map(int,readline().split())
    G[u - 1].append(v - 1)
    G[v - 1].append(u - 1)
dp = [0] * N
for i in range(N):
    if S[i] == "P":
        dp[i] = 1
        
T = "DCA"
for t in T:
    new_dp = [0] * N
    for v in range(N):
        if dp[v] == 0:
            continue
        for child in G[v]:
            if S[child] == t:
                new_dp[child] += dp[v]
                new_dp[child] %= DIV
    dp = new_dp
        
print(sum(dp) % DIV)        

0