結果

問題 No.762 PDCAパス
ユーザー convexineq
提出日時 2021-03-31 02:21:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 435 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 98,176 KB
最終ジャッジ日時 2024-12-14 04:43:04
合計ジャッジ時間 7,037 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
s = input()
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

from collections import defaultdict
d = {i:1 for i in range(n) if s[i]=="P"}
for B in "DCA":
    nd = defaultdict(int)
    for k,v in d.items():
        for c in g[k]:
            if s[c] == B:
                nd[c] += v
    d = nd
print(sum(d.values())%(10**9+7))
0