結果
問題 | No.762 PDCAパス |
ユーザー |
|
提出日時 | 2020-04-11 20:15:18 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,194 bytes |
コンパイル時間 | 133 ms |
コンパイル使用メモリ | 82,380 KB |
実行使用メモリ | 90,560 KB |
最終ジャッジ日時 | 2024-09-19 08:36:19 |
合計ジャッジ時間 | 7,909 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 38 |
ソースコード
import sys, refrom collections import deque, defaultdict, Counterfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radiansfrom itertools import accumulate, permutations, combinations, productfrom operator import itemgetter, mul, addfrom copy import deepcopyfrom string import ascii_lowercase, ascii_uppercase, digitsfrom bisect import bisect, bisect_leftfrom fractions import gcdfrom heapq import heappush, heappopfrom functools import reduce, lru_cachedef input(): return sys.stdin.readline().strip()def INT(): return int(input())def MAP(): return map(int, input().split())def LIST(): return list(map(int, input().split()))def ZIP(n): return zip(*(MAP() for _ in range(n)))sys.setrecursionlimit(10 ** 9)INF = float('inf')mod = 10 ** 9 + 7N, M = MAP()S = input()graph = [[] for _ in range(N)]for _ in range(M):a, b = MAP()graph[a-1].append(b-1)graph[b-1].append(a-1)step = {"P":1, "D":2, "C":3, "A":4}@lru_cache(maxsize=None)def DFS(n, s):if s == 4:return 1ret = 0for node in graph[n]:if s+1 == step[S[node]]:ret += DFS(node, s+1)return retans = 0for i in range(N):if S[i] == "P":ans += DFS(i, 1)ans %= modprint(ans)