結果

問題 No.762 PDCAパス
ユーザー YamadaYamada
提出日時 2018-12-27 21:40:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 710 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 23,808 KB
最終ジャッジ日時 2024-04-09 03:06:50
合計ジャッジ時間 10,101 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,880 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 29 ms
10,880 KB
testcase_03 AC 29 ms
10,752 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 30 ms
10,752 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 30 ms
10,880 KB
testcase_09 AC 30 ms
10,752 KB
testcase_10 AC 30 ms
10,752 KB
testcase_11 AC 29 ms
10,880 KB
testcase_12 AC 29 ms
10,752 KB
testcase_13 AC 29 ms
10,752 KB
testcase_14 AC 29 ms
10,752 KB
testcase_15 AC 29 ms
10,752 KB
testcase_16 AC 30 ms
10,752 KB
testcase_17 AC 29 ms
10,880 KB
testcase_18 AC 30 ms
10,752 KB
testcase_19 AC 29 ms
10,752 KB
testcase_20 AC 30 ms
10,752 KB
testcase_21 AC 31 ms
10,752 KB
testcase_22 AC 395 ms
14,976 KB
testcase_23 AC 396 ms
15,104 KB
testcase_24 AC 345 ms
23,808 KB
testcase_25 AC 350 ms
23,808 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 413 ms
18,176 KB
testcase_29 AC 419 ms
18,176 KB
testcase_30 AC 432 ms
17,664 KB
testcase_31 AC 422 ms
17,536 KB
testcase_32 AC 420 ms
17,664 KB
testcase_33 AC 414 ms
17,408 KB
testcase_34 AC 419 ms
17,536 KB
testcase_35 AC 418 ms
17,408 KB
testcase_36 AC 419 ms
16,384 KB
testcase_37 AC 413 ms
16,768 KB
testcase_38 AC 414 ms
16,640 KB
testcase_39 AC 406 ms
16,640 KB
testcase_40 AC 411 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)
0