結果
問題 | No.762 PDCAパス |
ユーザー | R ITSUMI |
提出日時 | 2020-09-27 04:47:20 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 570 bytes |
コンパイル時間 | 465 ms |
コンパイル使用メモリ | 86,716 KB |
実行使用メモリ | 84,880 KB |
最終ジャッジ日時 | 2023-09-12 17:14:00 |
合計ジャッジ時間 | 7,576 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
75,860 KB |
testcase_01 | AC | 73 ms
71,312 KB |
testcase_02 | AC | 74 ms
71,276 KB |
testcase_03 | AC | 72 ms
71,160 KB |
testcase_04 | AC | 74 ms
71,156 KB |
testcase_05 | AC | 72 ms
71,200 KB |
testcase_06 | AC | 73 ms
71,284 KB |
testcase_07 | AC | 75 ms
71,108 KB |
testcase_08 | AC | 73 ms
71,156 KB |
testcase_09 | AC | 74 ms
71,236 KB |
testcase_10 | AC | 74 ms
71,268 KB |
testcase_11 | AC | 73 ms
71,272 KB |
testcase_12 | AC | 73 ms
71,156 KB |
testcase_13 | AC | 74 ms
71,340 KB |
testcase_14 | AC | 73 ms
71,416 KB |
testcase_15 | AC | 74 ms
71,448 KB |
testcase_16 | AC | 75 ms
71,148 KB |
testcase_17 | AC | 75 ms
71,208 KB |
testcase_18 | AC | 75 ms
71,124 KB |
testcase_19 | AC | 74 ms
71,432 KB |
testcase_20 | AC | 74 ms
71,544 KB |
testcase_21 | AC | 74 ms
71,276 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 | -- | - |
ソースコード
MOD = 10**9 + 7 import sys sys.setrecursionlimit(10**7) next = {'P':'D','D':'C','C':'A','A':'P'} def dfs(v,path): path += S[v] if path == 'PDCA': return 1 res = 0 for i in graph[v]: if S[i] == next[S[v]]: res += dfs(i,path) return res N, M = map(int, input().split()) S = input() graph = [[] for _ in range(N)] for _ in range(M): u, v = map(int, input().split()) graph[u-1].append(v-1) graph[v-1].append(u-1) ans = 0 for i in range(N): if S[i] == 'P': ans += dfs(i,'') ans %= MOD print(ans)