結果

問題 No.762 PDCAパス
ユーザー convexineqconvexineq
提出日時 2021-03-31 02:15:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 91,172 KB
最終ジャッジ日時 2023-08-20 21:57:37
合計ジャッジ時間 8,257 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,036 KB
testcase_01 AC 77 ms
71,176 KB
testcase_02 AC 77 ms
71,128 KB
testcase_03 AC 77 ms
71,036 KB
testcase_04 AC 75 ms
71,228 KB
testcase_05 AC 75 ms
71,036 KB
testcase_06 AC 77 ms
71,016 KB
testcase_07 AC 76 ms
70,936 KB
testcase_08 AC 76 ms
71,204 KB
testcase_09 AC 76 ms
71,048 KB
testcase_10 AC 75 ms
71,264 KB
testcase_11 AC 76 ms
71,196 KB
testcase_12 AC 76 ms
71,200 KB
testcase_13 AC 76 ms
71,176 KB
testcase_14 AC 76 ms
70,756 KB
testcase_15 AC 74 ms
71,032 KB
testcase_16 AC 74 ms
71,156 KB
testcase_17 AC 74 ms
70,904 KB
testcase_18 AC 76 ms
70,920 KB
testcase_19 AC 73 ms
71,236 KB
testcase_20 AC 75 ms
71,096 KB
testcase_21 AC 74 ms
70,904 KB
testcase_22 AC 183 ms
79,684 KB
testcase_23 AC 158 ms
79,564 KB
testcase_24 AC 223 ms
90,732 KB
testcase_25 AC 223 ms
90,448 KB
testcase_26 AC 161 ms
79,892 KB
testcase_27 AC 159 ms
79,776 KB
testcase_28 AC 265 ms
91,172 KB
testcase_29 AC 266 ms
91,016 KB
testcase_30 AC 256 ms
88,472 KB
testcase_31 AC 257 ms
88,728 KB
testcase_32 AC 252 ms
88,492 KB
testcase_33 AC 247 ms
86,244 KB
testcase_34 AC 238 ms
86,624 KB
testcase_35 AC 234 ms
86,272 KB
testcase_36 AC 216 ms
82,632 KB
testcase_37 AC 224 ms
82,492 KB
testcase_38 AC 223 ms
82,704 KB
testcase_39 AC 229 ms
82,716 KB
testcase_40 AC 230 ms
82,568 KB
権限があれば一括ダウンロードができます

ソースコード

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)

MOD = 10**9+7
r = [int(si=="P") for si in s]
for A,B in ["PD","DC","CA"]:
    nr = [0]*n
    for i in range(n):
        if r[i] and s[i] == A:
            for c in g[i]:
                if s[c] == B:
                    nr[c] += r[i]
                    nr[c] %= MOD
    r = nr
print(sum(r)%MOD)
0