結果

問題 No.762 PDCAパス
ユーザー flippergoflippergo
提出日時 2021-01-05 15:13:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 708 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 94,464 KB
最終ジャッジ日時 2024-04-23 19:38:35
合計ジャッジ時間 6,590 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,096 KB
testcase_01 AC 42 ms
52,224 KB
testcase_02 AC 40 ms
51,968 KB
testcase_03 AC 40 ms
51,968 KB
testcase_04 AC 40 ms
52,096 KB
testcase_05 AC 40 ms
51,840 KB
testcase_06 AC 44 ms
51,840 KB
testcase_07 AC 40 ms
51,712 KB
testcase_08 AC 41 ms
52,224 KB
testcase_09 AC 40 ms
51,968 KB
testcase_10 AC 40 ms
51,712 KB
testcase_11 AC 40 ms
51,840 KB
testcase_12 AC 39 ms
52,224 KB
testcase_13 AC 40 ms
52,096 KB
testcase_14 AC 41 ms
52,224 KB
testcase_15 AC 41 ms
52,224 KB
testcase_16 AC 42 ms
52,224 KB
testcase_17 AC 41 ms
52,352 KB
testcase_18 AC 40 ms
51,968 KB
testcase_19 AC 40 ms
52,224 KB
testcase_20 AC 40 ms
51,968 KB
testcase_21 AC 40 ms
52,096 KB
testcase_22 AC 139 ms
78,976 KB
testcase_23 AC 139 ms
78,848 KB
testcase_24 AC 240 ms
93,824 KB
testcase_25 AC 231 ms
93,952 KB
testcase_26 AC 141 ms
78,976 KB
testcase_27 AC 141 ms
79,488 KB
testcase_28 AC 290 ms
94,464 KB
testcase_29 AC 280 ms
94,080 KB
testcase_30 AC 260 ms
90,240 KB
testcase_31 AC 266 ms
90,496 KB
testcase_32 AC 261 ms
90,368 KB
testcase_33 AC 238 ms
85,596 KB
testcase_34 AC 236 ms
85,596 KB
testcase_35 AC 247 ms
85,592 KB
testcase_36 AC 196 ms
81,964 KB
testcase_37 AC 202 ms
82,048 KB
testcase_38 AC 204 ms
81,920 KB
testcase_39 AC 204 ms
82,048 KB
testcase_40 AC 198 ms
82,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p = 10**9+7
N,M = map(int,input().split())
S = input().strip()
S = "0"+S
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
    u,v = map(int,input().split())
    G[u].append(v)
    G[v].append(u)
A = [0 for _ in range(N+1)]
for i in range(1,N+1):
    if S[i]=="P":
        A[i]=1
        for j in G[i]:
            if S[j]=="D":
                A[j] = (A[j]+A[i])%p
for i in range(1,N+1):
    if S[i]=="D":
        for j in G[i]:
            if S[j]=="C":
                A[j] = (A[j]+A[i])%p
for i in range(1,N+1):
    if S[i]=="C":
        for j in G[i]:
            if S[j]=="A":
                A[j] = (A[j]+A[i])%p
cnt = 0
for i in range(1,N+1):
    if S[i]=="A":
        cnt = (cnt+A[i])%p
print(cnt)
0