結果

問題 No.762 PDCAパス
ユーザー matsu7874matsu7874
提出日時 2018-11-28 02:18:01
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 911 bytes
コンパイル時間 668 ms
コンパイル使用メモリ 10,848 KB
実行使用メモリ 29,892 KB
最終ジャッジ日時 2023-09-07 08:53:22
合計ジャッジ時間 8,943 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 15 ms
8,556 KB
testcase_02 WA -
testcase_03 AC 14 ms
8,712 KB
testcase_04 AC 15 ms
8,548 KB
testcase_05 AC 15 ms
8,504 KB
testcase_06 AC 14 ms
8,712 KB
testcase_07 AC 15 ms
8,484 KB
testcase_08 AC 15 ms
8,524 KB
testcase_09 AC 15 ms
8,668 KB
testcase_10 AC 16 ms
8,544 KB
testcase_11 WA -
testcase_12 AC 15 ms
8,520 KB
testcase_13 AC 14 ms
8,644 KB
testcase_14 AC 15 ms
8,560 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 14 ms
8,668 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 304 ms
29,892 KB
testcase_25 AC 292 ms
29,736 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
mod = 10**9 + 7

n, m = map(int, input().split())

s = input()

graph = [[] for i in range(n)]
edges = {
    'PD': [],
    'DC': [],
    'CA': [],
}
for _ in range(m):
    u, v = map(lambda x: int(x) - 1, input().split())
    if s[u] == 'P':
        if s[v] == 'D':
            edges['PD'].append((u, v))
    elif s[u] == 'D':
        if s[v] == 'C':
            edges['DC'].append((u, v))
        elif s[v] == 'P':
            edges['PD'].append((v, u))
    elif s[u] == 'C':
        if s[v] == 'A':
            edges['CA'].append((u, v))
        elif s[v] == 'D':
            edges['DC'].append((v, u))
    elif s[u] == 'A':
        if s[v] == 'C':
            edges['CA'].append((v, u))

cnt = collections.defaultdict(int)


for u, v in edges['PD']:
    cnt[v] += 1

for u, v in edges['DC']:
    cnt[v] += cnt[u]

total = 0
for u, v in edges['DC']:
    total += cnt[u]

print(total % mod)
0