結果

問題 No.762 PDCAパス
ユーザー roarisroaris
提出日時 2019-12-22 12:34:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 89,044 KB
最終ジャッジ日時 2023-10-12 03:44:00
合計ジャッジ時間 7,389 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,312 KB
testcase_01 AC 68 ms
71,408 KB
testcase_02 AC 74 ms
71,208 KB
testcase_03 AC 68 ms
71,492 KB
testcase_04 AC 68 ms
71,088 KB
testcase_05 AC 69 ms
71,280 KB
testcase_06 AC 70 ms
71,204 KB
testcase_07 AC 78 ms
71,436 KB
testcase_08 AC 69 ms
71,232 KB
testcase_09 AC 68 ms
71,336 KB
testcase_10 AC 70 ms
71,200 KB
testcase_11 AC 69 ms
71,136 KB
testcase_12 AC 69 ms
71,148 KB
testcase_13 AC 68 ms
71,220 KB
testcase_14 AC 72 ms
71,424 KB
testcase_15 AC 69 ms
71,412 KB
testcase_16 AC 69 ms
71,236 KB
testcase_17 AC 70 ms
71,244 KB
testcase_18 AC 68 ms
71,136 KB
testcase_19 AC 72 ms
71,204 KB
testcase_20 AC 69 ms
71,404 KB
testcase_21 AC 70 ms
71,136 KB
testcase_22 AC 108 ms
78,340 KB
testcase_23 AC 106 ms
78,520 KB
testcase_24 AC 162 ms
87,848 KB
testcase_25 AC 171 ms
87,808 KB
testcase_26 AC 115 ms
79,820 KB
testcase_27 AC 118 ms
79,728 KB
testcase_28 AC 200 ms
88,928 KB
testcase_29 AC 230 ms
89,044 KB
testcase_30 AC 225 ms
86,952 KB
testcase_31 AC 215 ms
86,736 KB
testcase_32 AC 217 ms
86,700 KB
testcase_33 AC 199 ms
84,880 KB
testcase_34 AC 203 ms
85,084 KB
testcase_35 AC 200 ms
85,192 KB
testcase_36 AC 175 ms
82,380 KB
testcase_37 AC 169 ms
82,392 KB
testcase_38 AC 170 ms
82,152 KB
testcase_39 AC 169 ms
82,392 KB
testcase_40 AC 168 ms
82,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
S = input()
adj_list = [[] for _ in range(N)]

for _ in range(M):
    ui, vi = map(int, input().split())
    adj_list[ui-1].append(vi-1)
    adj_list[vi-1].append(ui-1)

cnt = [0]*N

for v in range(N):
    if S[v] in ['P', 'A']:
        continue
    
    if S[v]=='D':
        for nv in adj_list[v]:
            if S[nv]=='P':
                cnt[v] += 1
    elif S[v]=='C':
        for nv in adj_list[v]:
            if S[nv]=='A':
                cnt[v] += 1

ans = 0
MOD = 10**9+7

for v in range(N):
    if S[v]=='D':
        for nv in adj_list[v]:
            if S[nv]=='C':
                ans += cnt[v]*cnt[nv]
                ans %= MOD

print(ans)
0