結果

問題 No.762 PDCAパス
ユーザー YamadaYamada
提出日時 2018-12-27 21:41:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 437 ms / 2,000 ms
コード長 721 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 24,064 KB
最終ジャッジ日時 2024-04-09 03:07:19
合計ジャッジ時間 9,965 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 29 ms
10,752 KB
testcase_05 AC 28 ms
10,880 KB
testcase_06 AC 28 ms
10,880 KB
testcase_07 AC 28 ms
10,752 KB
testcase_08 AC 28 ms
10,752 KB
testcase_09 AC 31 ms
10,752 KB
testcase_10 AC 28 ms
10,752 KB
testcase_11 AC 29 ms
10,752 KB
testcase_12 AC 30 ms
10,880 KB
testcase_13 AC 28 ms
10,752 KB
testcase_14 AC 29 ms
10,752 KB
testcase_15 AC 29 ms
10,752 KB
testcase_16 AC 29 ms
10,752 KB
testcase_17 AC 29 ms
10,880 KB
testcase_18 AC 28 ms
10,880 KB
testcase_19 AC 29 ms
10,880 KB
testcase_20 AC 29 ms
10,752 KB
testcase_21 AC 28 ms
10,752 KB
testcase_22 AC 403 ms
15,104 KB
testcase_23 AC 400 ms
14,976 KB
testcase_24 AC 344 ms
23,936 KB
testcase_25 AC 353 ms
24,064 KB
testcase_26 AC 434 ms
23,296 KB
testcase_27 AC 437 ms
23,424 KB
testcase_28 AC 424 ms
18,048 KB
testcase_29 AC 409 ms
18,304 KB
testcase_30 AC 414 ms
17,792 KB
testcase_31 AC 421 ms
17,920 KB
testcase_32 AC 416 ms
17,920 KB
testcase_33 AC 418 ms
17,408 KB
testcase_34 AC 421 ms
17,408 KB
testcase_35 AC 412 ms
17,664 KB
testcase_36 AC 418 ms
16,640 KB
testcase_37 AC 419 ms
16,768 KB
testcase_38 AC 413 ms
16,768 KB
testcase_39 AC 413 ms
16,768 KB
testcase_40 AC 407 ms
16,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0