結果

問題 No.762 PDCAパス
ユーザー tcltktcltk
提出日時 2021-01-16 11:19:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 546 ms / 2,000 ms
コード長 1,136 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 118,284 KB
最終ジャッジ日時 2023-08-18 07:38:02
合計ジャッジ時間 15,436 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 232 ms
83,468 KB
testcase_01 AC 234 ms
83,360 KB
testcase_02 AC 233 ms
83,200 KB
testcase_03 AC 231 ms
83,128 KB
testcase_04 AC 227 ms
83,128 KB
testcase_05 AC 230 ms
83,332 KB
testcase_06 AC 230 ms
83,316 KB
testcase_07 AC 227 ms
83,468 KB
testcase_08 AC 226 ms
83,040 KB
testcase_09 AC 228 ms
83,500 KB
testcase_10 AC 230 ms
83,436 KB
testcase_11 AC 237 ms
83,088 KB
testcase_12 AC 225 ms
83,328 KB
testcase_13 AC 229 ms
83,380 KB
testcase_14 AC 228 ms
83,240 KB
testcase_15 AC 231 ms
83,488 KB
testcase_16 AC 231 ms
82,988 KB
testcase_17 AC 232 ms
83,132 KB
testcase_18 AC 232 ms
83,260 KB
testcase_19 AC 237 ms
83,384 KB
testcase_20 AC 225 ms
83,288 KB
testcase_21 AC 227 ms
83,316 KB
testcase_22 AC 286 ms
89,044 KB
testcase_23 AC 287 ms
88,884 KB
testcase_24 AC 457 ms
115,704 KB
testcase_25 AC 460 ms
115,520 KB
testcase_26 AC 339 ms
88,260 KB
testcase_27 AC 349 ms
88,272 KB
testcase_28 AC 546 ms
118,284 KB
testcase_29 AC 533 ms
118,064 KB
testcase_30 AC 506 ms
111,784 KB
testcase_31 AC 503 ms
112,032 KB
testcase_32 AC 507 ms
111,764 KB
testcase_33 AC 471 ms
105,552 KB
testcase_34 AC 471 ms
105,588 KB
testcase_35 AC 464 ms
105,280 KB
testcase_36 AC 393 ms
95,680 KB
testcase_37 AC 374 ms
95,336 KB
testcase_38 AC 383 ms
95,448 KB
testcase_39 AC 368 ms
95,712 KB
testcase_40 AC 364 ms
95,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#region Header
#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
from queue import PriorityQueue
import bisect
import heapq

def input():
    return sys.stdin.readline()[:-1]

sys.setrecursionlimit(1000000)
#endregion

# _INPUT = """# paste here...
# """
# sys.stdin = io.StringIO(_INPUT)

MOD = 1000000007

# def solve(N: int, M: int, S: str, u: List[int], v: List[int]) -> int:
def solve(N, M, S, u, v):
    pass  # TODO: edit here

def main():
    N, M = map(int, input().split())
    S = input()
    G = [[list() for _ in range(4)] for _ in range(N)]
    for _ in range(M):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        i = 'PDCA'.index(S[u])
        j = 'PDCA'.index(S[v])
        G[u][j].append(v)
        G[v][i].append(u)

    count = 0
    for i in range(N):
        if S[i] == 'P':
            for j in G[i][1]:
                for k in G[j][2]:
                    count = (count + len(G[k][3])) % MOD
    print(count)

if __name__ == '__main__':
    main()
0