結果

問題 No.762 PDCAパス
ユーザー Konton7Konton7
提出日時 2019-05-15 23:24:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 388 ms / 2,000 ms
コード長 727 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 10,716 KB
実行使用メモリ 13,412 KB
最終ジャッジ日時 2023-10-12 17:35:02
合計ジャッジ時間 10,360 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,892 KB
testcase_01 AC 15 ms
7,916 KB
testcase_02 AC 15 ms
7,948 KB
testcase_03 AC 15 ms
8,076 KB
testcase_04 AC 15 ms
7,948 KB
testcase_05 AC 15 ms
8,176 KB
testcase_06 AC 15 ms
7,936 KB
testcase_07 AC 15 ms
7,804 KB
testcase_08 AC 15 ms
7,936 KB
testcase_09 AC 16 ms
7,916 KB
testcase_10 AC 16 ms
7,940 KB
testcase_11 AC 15 ms
7,924 KB
testcase_12 AC 15 ms
7,992 KB
testcase_13 AC 15 ms
7,928 KB
testcase_14 AC 15 ms
7,956 KB
testcase_15 AC 15 ms
8,012 KB
testcase_16 AC 16 ms
7,932 KB
testcase_17 AC 15 ms
8,060 KB
testcase_18 AC 16 ms
8,084 KB
testcase_19 AC 15 ms
8,092 KB
testcase_20 AC 15 ms
7,924 KB
testcase_21 AC 15 ms
7,972 KB
testcase_22 AC 342 ms
9,548 KB
testcase_23 AC 347 ms
9,580 KB
testcase_24 AC 297 ms
13,384 KB
testcase_25 AC 298 ms
13,412 KB
testcase_26 AC 351 ms
12,428 KB
testcase_27 AC 358 ms
12,472 KB
testcase_28 AC 388 ms
11,444 KB
testcase_29 AC 374 ms
11,508 KB
testcase_30 AC 383 ms
11,220 KB
testcase_31 AC 380 ms
11,300 KB
testcase_32 AC 378 ms
11,384 KB
testcase_33 AC 375 ms
10,612 KB
testcase_34 AC 374 ms
10,668 KB
testcase_35 AC 373 ms
10,700 KB
testcase_36 AC 361 ms
10,040 KB
testcase_37 AC 366 ms
10,260 KB
testcase_38 AC 365 ms
10,228 KB
testcase_39 AC 367 ms
10,240 KB
testcase_40 AC 368 ms
10,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = [ int(v) for v in input().split() ]
s = input()

mod = 1000000007

dlist= [ 0 for i in range(n) ]
clist= [ 0 for i in range(n) ]
dclist = []

for i in range(m):
    x, y = [ int(v) for v in input().split() ]
    if s[x-1] == "P" and s[y-1] == "D":
        dlist[y-1] += 1
        
    elif s[x-1] == "D" and s[y-1] == "P":
        dlist[x-1] += 1

    elif s[x-1] == "D" and s[y-1] == "C":
        dclist.append([x-1,y-1])

    elif s[x-1] == "C" and s[y-1] == "D":
        dclist.append([y-1,x-1])

    elif s[x-1] == "C" and s[y-1] == "A":
        clist[x-1] += 1

    elif s[x-1] == "A" and s[y-1] == "C":
        clist[y-1] += 1



s = 0
for i in dclist:
    s += (dlist[i[0]]*clist[i[1]]) 

ans = s % mod
print(ans)
0