結果
問題 | No.762 PDCAパス |
ユーザー |
![]() |
提出日時 | 2024-12-19 20:36:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 144 ms / 2,000 ms |
コード長 | 390 bytes |
コンパイル時間 | 399 ms |
コンパイル使用メモリ | 82,032 KB |
実行使用メモリ | 84,788 KB |
最終ジャッジ日時 | 2024-12-19 20:36:24 |
合計ジャッジ時間 | 6,302 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
N,M=map(int,input().split())S=input()mod=10**9+7edegs=[]for m in range(M):u,v=map(int,input().split())u-=1;v-=1edegs.append((u,v))dp=[s=="P" for s in S]for t in "DCA":prev=dpdp=[0]*Nfor u,v in edegs:dp[u]+=prev[v]dp[v]+=prev[u]for x in range(N):dp[x]%=modif t!=S[x]:dp[x]=0ans=sum(dp)%modprint(ans)