結果

問題 No.762 PDCAパス
ユーザー DrDrpilotDrDrpilot
提出日時 2022-01-24 18:29:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 554 bytes
コンパイル時間 1,126 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 820,784 KB
最終ジャッジ日時 2023-08-21 07:35:11
合計ジャッジ時間 6,877 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,472 KB
testcase_01 AC 19 ms
8,504 KB
testcase_02 AC 19 ms
8,636 KB
testcase_03 AC 18 ms
8,544 KB
testcase_04 AC 19 ms
8,460 KB
testcase_05 AC 18 ms
8,508 KB
testcase_06 AC 19 ms
8,468 KB
testcase_07 AC 18 ms
8,628 KB
testcase_08 AC 18 ms
8,508 KB
testcase_09 AC 19 ms
8,548 KB
testcase_10 AC 18 ms
8,508 KB
testcase_11 AC 18 ms
8,672 KB
testcase_12 AC 18 ms
8,592 KB
testcase_13 AC 19 ms
8,640 KB
testcase_14 AC 18 ms
8,472 KB
testcase_15 AC 18 ms
8,592 KB
testcase_16 AC 19 ms
8,520 KB
testcase_17 AC 19 ms
8,632 KB
testcase_18 AC 19 ms
8,672 KB
testcase_19 AC 18 ms
8,468 KB
testcase_20 AC 18 ms
8,588 KB
testcase_21 AC 19 ms
8,532 KB
testcase_22 MLE -
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 #

n,m=map(int,input().split())
S='PDCA'
s='#'+input()
g=[[] for _ in range(n+1)]
for _ in range(m):
    u,v=map(int,input().split())
    if S.index(s[u])-S.index(s[v])==1:
        g[v].append(u)
    elif S.index(s[v])-S.index(s[u])==1:
        g[u].append(v)
from collections import deque
q=deque()
mod=10**9+7
ans=0
for i in range(1,n+1):
    if s[i]=='P' and len(g[i])>0:
        q.append((i,1))
while q:
    now,cnt=q.popleft()
    if cnt==4:
        ans+=1
        ans%=mod
        continue
    for to in g[now]:
        q.append((to,cnt+1))
print(ans)
0