結果
問題 | No.762 PDCAパス |
ユーザー | DrDrpilot |
提出日時 | 2022-03-22 18:10:40 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 554 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 82,412 KB |
実行使用メモリ | 848,352 KB |
最終ジャッジ日時 | 2024-04-18 17:07:34 |
合計ジャッジ時間 | 4,815 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
54,140 KB |
testcase_01 | AC | 36 ms
54,556 KB |
testcase_02 | AC | 39 ms
54,732 KB |
testcase_03 | AC | 35 ms
54,072 KB |
testcase_04 | AC | 36 ms
54,592 KB |
testcase_05 | AC | 40 ms
53,868 KB |
testcase_06 | AC | 37 ms
54,308 KB |
testcase_07 | AC | 35 ms
54,020 KB |
testcase_08 | AC | 36 ms
54,652 KB |
testcase_09 | AC | 36 ms
53,284 KB |
testcase_10 | AC | 36 ms
54,344 KB |
testcase_11 | AC | 36 ms
54,876 KB |
testcase_12 | AC | 35 ms
55,468 KB |
testcase_13 | AC | 35 ms
53,840 KB |
testcase_14 | AC | 40 ms
54,156 KB |
testcase_15 | AC | 37 ms
54,744 KB |
testcase_16 | AC | 37 ms
54,276 KB |
testcase_17 | AC | 36 ms
55,296 KB |
testcase_18 | AC | 36 ms
53,852 KB |
testcase_19 | AC | 36 ms
54,344 KB |
testcase_20 | AC | 35 ms
54,144 KB |
testcase_21 | AC | 37 ms
53,836 KB |
testcase_22 | MLE | - |
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 | -- | - |
ソースコード
n,m=map(int,input().split()) S='PDCA' s='#'+input() g=[[] for _ in range(n+1)] for _ in range(m): u,v=map(int,input().split()) if S.index(s[u])-S.index(s[v])==1: g[v].append(u) elif S.index(s[v])-S.index(s[u])==1: g[u].append(v) from collections import deque q=deque() mod=10**9+7 ans=0 for i in range(1,n+1): if s[i]=='P' and len(g[i])>0: q.append((i,1)) while q: now,cnt=q.popleft() if cnt==4: ans+=1 ans%=mod continue for to in g[now]: q.append((to,cnt+1)) print(ans)