結果

問題 No.762 PDCAパス
ユーザー brthyyjpbrthyyjp
提出日時 2021-04-30 18:02:19
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 737 bytes
コンパイル時間 997 ms
コンパイル使用メモリ 86,420 KB
実行使用メモリ 83,868 KB
最終ジャッジ日時 2023-09-25 18:55:50
合計ジャッジ時間 8,140 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
75,268 KB
testcase_01 AC 72 ms
71,024 KB
testcase_02 AC 71 ms
71,044 KB
testcase_03 AC 72 ms
70,972 KB
testcase_04 AC 73 ms
70,844 KB
testcase_05 AC 72 ms
70,988 KB
testcase_06 AC 73 ms
71,016 KB
testcase_07 AC 73 ms
70,996 KB
testcase_08 AC 74 ms
70,940 KB
testcase_09 AC 73 ms
70,672 KB
testcase_10 AC 72 ms
70,676 KB
testcase_11 AC 71 ms
70,856 KB
testcase_12 AC 71 ms
70,892 KB
testcase_13 AC 70 ms
71,036 KB
testcase_14 AC 71 ms
71,028 KB
testcase_15 AC 71 ms
70,876 KB
testcase_16 AC 72 ms
71,020 KB
testcase_17 AC 73 ms
70,872 KB
testcase_18 AC 72 ms
71,016 KB
testcase_19 AC 71 ms
71,008 KB
testcase_20 AC 72 ms
70,940 KB
testcase_21 AC 71 ms
70,788 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
        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]])
for v in range(n):
    if s[v] == 'P':
        dfs(v, ['P'])
print(res[0]%mod)
0