結果
| 問題 | No.762 PDCAパス | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-11-06 11:43:41 | 
| 言語 | Python2 (2.7.18) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 354 ms / 2,000 ms | 
| コード長 | 476 bytes | 
| コンパイル時間 | 597 ms | 
| コンパイル使用メモリ | 6,784 KB | 
| 実行使用メモリ | 14,208 KB | 
| 最終ジャッジ日時 | 2024-09-15 00:19:00 | 
| 合計ジャッジ時間 | 9,336 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 38 | 
ソースコード
#yuki762 n,m=map(int,raw_input().split()) s=raw_input() lc=[0]*n ld=[0]*n l=[] for i in range(m): x,y=map(int,raw_input().split()) x-=1 y-=1 if s[x]=='P' and s[y]=='D': ld[y]+=1 elif s[x]=='D' and s[y]=='P': ld[x]+=1 elif s[x]=='D' and s[y]=='C': l.append([x,y]) elif s[x]=='C' and s[y]=='D': l.append([y,x]) elif s[x]=='C' and s[y]=='A': lc[x]+=1 elif s[x]=='A' and s[y]=='C': lc[y]+=1 res=0 for i in l: res+=(ld[i[0]]*lc[i[1]]) res%=10**9+7 print res
