結果
| 問題 | No.762 PDCAパス | 
| コンテスト | |
| ユーザー |  Yamada | 
| 提出日時 | 2018-12-27 21:41:48 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 405 ms / 2,000 ms | 
| コード長 | 721 bytes | 
| コンパイル時間 | 91 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 24,064 KB | 
| 最終ジャッジ日時 | 2024-10-01 14:55:23 | 
| 合計ジャッジ時間 | 9,174 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 38 | 
ソースコード
N,M =map(int,input().split())
str =input()
pdca ={l:list() for l in ["PD","DC","CA"]}
for i in range(M):
    s,t =map(int,input().split())
    str2 =str[s-1]+str[t-1]
    if str2 =="PD":
        pdca["PD"].append([s,t])
    elif str2 =="DP":
        pdca["PD"].append([t,s])
    elif str2 =="DC":
        pdca["DC"].append([s,t])
    elif str2 =="CD":
        pdca["DC"].append([t,s])
    elif str2 =="CA":
        pdca["CA"].append([s,t])
    elif str2 =="AC":
        pdca["CA"].append([t,s])
sum = 0
dclist =[0]*N
calist =[0]*N
for lis in pdca["CA"]:
    calist[lis[0]-1] += 1
for lis in pdca["DC"]:
    dclist[lis[0]-1] += calist[lis[1]-1]
for lis in pdca["PD"]:
    sum += dclist[lis[1]-1]
print(sum%1000000007)
            
            
            
        