結果

問題 No.762 PDCAパス
ユーザー ttrttr
提出日時 2020-02-09 18:46:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 599 ms / 2,000 ms
コード長 683 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 27,264 KB
最終ジャッジ日時 2024-04-08 12:29:20
合計ジャッジ時間 12,788 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,112 KB
testcase_01 AC 32 ms
10,112 KB
testcase_02 AC 32 ms
10,112 KB
testcase_03 AC 31 ms
10,112 KB
testcase_04 AC 32 ms
10,112 KB
testcase_05 AC 31 ms
10,112 KB
testcase_06 AC 34 ms
10,112 KB
testcase_07 AC 31 ms
10,112 KB
testcase_08 AC 32 ms
10,112 KB
testcase_09 AC 33 ms
10,112 KB
testcase_10 AC 36 ms
10,112 KB
testcase_11 AC 33 ms
10,112 KB
testcase_12 AC 34 ms
10,112 KB
testcase_13 AC 32 ms
10,112 KB
testcase_14 AC 32 ms
10,112 KB
testcase_15 AC 31 ms
10,112 KB
testcase_16 AC 33 ms
10,112 KB
testcase_17 AC 32 ms
10,112 KB
testcase_18 AC 33 ms
10,112 KB
testcase_19 AC 33 ms
10,112 KB
testcase_20 AC 33 ms
10,112 KB
testcase_21 AC 32 ms
10,112 KB
testcase_22 AC 351 ms
14,848 KB
testcase_23 AC 348 ms
14,848 KB
testcase_24 AC 486 ms
25,984 KB
testcase_25 AC 475 ms
25,984 KB
testcase_26 AC 368 ms
16,256 KB
testcase_27 AC 360 ms
16,256 KB
testcase_28 AC 597 ms
27,264 KB
testcase_29 AC 599 ms
27,264 KB
testcase_30 AC 569 ms
25,088 KB
testcase_31 AC 562 ms
25,088 KB
testcase_32 AC 562 ms
25,088 KB
testcase_33 AC 550 ms
22,656 KB
testcase_34 AC 532 ms
22,656 KB
testcase_35 AC 531 ms
22,656 KB
testcase_36 AC 475 ms
19,968 KB
testcase_37 AC 473 ms
19,968 KB
testcase_38 AC 470 ms
19,968 KB
testcase_39 AC 466 ms
19,968 KB
testcase_40 AC 471 ms
19,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int, input().split())
S = input()
E = [[] for _ in range(N)]
for _ in range(M):
    u,v = map(int, input().split())
    E[u-1].append(v-1)
    E[v-1].append(u-1)

mod = 10**9+7
PDCA = [0]*N
for i in range(N):
    if S[i] != "P":
        continue
    for v in E[i]:
        if S[v] == "D":
            PDCA[v] += 1
for i in range(N):
    if S[i] != "D":
        continue
    for v in E[i]:
        if S[v] == "C":
            PDCA[v] += PDCA[i]
for i in range(N):
    if S[i] != "C":
        continue
    for v in E[i]:
        if S[v] == "A":
            PDCA[v] += PDCA[i]
ans = 0
for i in range(N):
    if S[i] == "A":
        ans += PDCA[i]
        ans %= mod
print(ans)
0