結果

問題 No.762 PDCAパス
ユーザー brthyyjpbrthyyjp
提出日時 2021-04-30 18:03:40
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 770 bytes
コンパイル時間 461 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 71,552 KB
最終ジャッジ日時 2023-09-25 18:57:20
合計ジャッジ時間 7,578 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,232 KB
testcase_01 AC 76 ms
71,300 KB
testcase_02 AC 75 ms
71,128 KB
testcase_03 AC 76 ms
71,200 KB
testcase_04 AC 74 ms
71,200 KB
testcase_05 AC 73 ms
71,168 KB
testcase_06 AC 73 ms
71,432 KB
testcase_07 AC 73 ms
71,336 KB
testcase_08 AC 72 ms
71,468 KB
testcase_09 AC 73 ms
71,332 KB
testcase_10 AC 73 ms
70,984 KB
testcase_11 AC 74 ms
71,344 KB
testcase_12 AC 74 ms
71,228 KB
testcase_13 AC 73 ms
71,220 KB
testcase_14 AC 73 ms
71,196 KB
testcase_15 AC 74 ms
71,228 KB
testcase_16 AC 74 ms
71,328 KB
testcase_17 AC 73 ms
71,260 KB
testcase_18 AC 73 ms
71,232 KB
testcase_19 AC 75 ms
71,552 KB
testcase_20 AC 75 ms
71,500 KB
testcase_21 AC 74 ms
71,196 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n, m = map(int, input().split())
s = str(input().rstrip())
g = [[] for i in range(n)]
mod = 10**9+7
for i in range(m):
    u, v = map(int, input().split())
    u, v = u-1, v-1
    g[u].append(v)
    g[v].append(u)

res = [0]
def dfs(v, A):
    if len(A) == 4:
        res[0] += 1
        res[0] %= mod
        return
    for u in g[v]:
        if A[-1] == 'P':
            if s[u] == 'D':
                dfs(u, A+[s[u]])
        elif A[-1] == 'D':
            if s[u] == 'C':
                dfs(u, A+[s[u]])
        elif A[-1] == 'C':
            if s[u] == 'A':
                dfs(u, A+[s[u]])
    return
for v in range(n):
    if s[v] == 'P':
        dfs(v, ['P'])
print(res[0]%mod)
0