結果
| 問題 |
No.762 PDCAパス
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-02-02 14:31:38 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 314 ms / 2,000 ms |
| コード長 | 501 bytes |
| コンパイル時間 | 86 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 35,616 KB |
| 最終ジャッジ日時 | 2024-09-18 20:44:44 |
| 合計ジャッジ時間 | 8,520 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,M = map(int,readline().split())
words = '$' + readline().decode().rstrip()
m = map(int,read().split())
UV = tuple(zip(m,m))
MOD = 10**9 + 7
UV += tuple((v,u) for u,v in UV)
dp = [1 * (s == 'P') for s in words]
for T in 'DCA':
newdp = [0] * (N+1)
for u,v in UV:
if words[v] == T:
newdp[v] += dp[u]
dp = newdp
answer = sum(dp) % MOD
print(answer)
maspy