結果
問題 | No.762 PDCAパス |
ユーザー | R ITSUMI |
提出日時 | 2020-06-23 23:34:33 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 711 bytes |
コンパイル時間 | 267 ms |
コンパイル使用メモリ | 87,216 KB |
実行使用メモリ | 95,988 KB |
最終ジャッジ日時 | 2023-09-16 20:20:03 |
合計ジャッジ時間 | 7,439 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 76 ms
75,900 KB |
testcase_01 | AC | 76 ms
71,140 KB |
testcase_02 | AC | 76 ms
71,140 KB |
testcase_03 | AC | 75 ms
71,224 KB |
testcase_04 | AC | 75 ms
71,432 KB |
testcase_05 | AC | 75 ms
71,224 KB |
testcase_06 | AC | 76 ms
71,252 KB |
testcase_07 | AC | 75 ms
71,260 KB |
testcase_08 | AC | 76 ms
71,320 KB |
testcase_09 | AC | 75 ms
70,928 KB |
testcase_10 | AC | 75 ms
71,220 KB |
testcase_11 | AC | 75 ms
71,224 KB |
testcase_12 | AC | 76 ms
71,344 KB |
testcase_13 | AC | 75 ms
71,260 KB |
testcase_14 | AC | 75 ms
71,272 KB |
testcase_15 | AC | 76 ms
71,416 KB |
testcase_16 | AC | 79 ms
75,084 KB |
testcase_17 | AC | 75 ms
71,252 KB |
testcase_18 | AC | 76 ms
71,204 KB |
testcase_19 | AC | 76 ms
71,432 KB |
testcase_20 | AC | 75 ms
71,220 KB |
testcase_21 | AC | 75 ms
71,028 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 | -- | - |
ソースコード
import sys sys.setrecursionlimit(10**7) N, M = map(int, input().split()) S = input() G = [list(map(int, input().split())) for _ in range(M)] edges = [[] for _ in range(N)] for a, b in G: edges[a - 1].append(b - 1) edges[b - 1].append(a - 1) def dfs(start,path): ans = 0 check = 'PDCA' path.append(S[start]) for i in range(min(4,len(path))): if path[i] != check[i]: path.pop() return 0 if ''.join(path) == 'PDCA': path.pop() return 1 elif len(path) > 4: path.pop() return 0 for i in edges[start]: ans += dfs(i,path) path.pop() return ans ans = 0 for i in range(N): ans += dfs(i,[]) print(ans)