結果

問題 No.762 PDCAパス
ユーザー tcltktcltk
提出日時 2021-01-16 11:18:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,121 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 118,080 KB
最終ジャッジ日時 2023-08-18 07:37:12
合計ジャッジ時間 15,265 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 229 ms
83,492 KB
testcase_01 AC 232 ms
82,996 KB
testcase_02 AC 231 ms
83,200 KB
testcase_03 AC 236 ms
83,448 KB
testcase_04 AC 231 ms
83,324 KB
testcase_05 AC 230 ms
83,456 KB
testcase_06 AC 232 ms
83,260 KB
testcase_07 AC 230 ms
83,320 KB
testcase_08 AC 228 ms
83,488 KB
testcase_09 AC 236 ms
83,324 KB
testcase_10 AC 234 ms
82,968 KB
testcase_11 AC 237 ms
83,252 KB
testcase_12 AC 234 ms
83,328 KB
testcase_13 AC 228 ms
82,964 KB
testcase_14 AC 230 ms
83,380 KB
testcase_15 AC 232 ms
83,516 KB
testcase_16 AC 231 ms
83,528 KB
testcase_17 AC 232 ms
83,384 KB
testcase_18 AC 235 ms
83,084 KB
testcase_19 AC 232 ms
83,072 KB
testcase_20 AC 235 ms
83,044 KB
testcase_21 AC 229 ms
83,224 KB
testcase_22 AC 289 ms
88,908 KB
testcase_23 AC 289 ms
88,564 KB
testcase_24 AC 410 ms
115,356 KB
testcase_25 AC 423 ms
115,312 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 497 ms
118,068 KB
testcase_29 AC 492 ms
118,080 KB
testcase_30 AC 469 ms
112,216 KB
testcase_31 AC 465 ms
112,012 KB
testcase_32 AC 480 ms
111,980 KB
testcase_33 AC 418 ms
105,592 KB
testcase_34 AC 422 ms
105,580 KB
testcase_35 AC 418 ms
105,256 KB
testcase_36 AC 362 ms
95,744 KB
testcase_37 AC 357 ms
95,752 KB
testcase_38 AC 368 ms
95,300 KB
testcase_39 AC 366 ms
95,456 KB
testcase_40 AC 358 ms
95,596 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 += len(G[k][3])
    print(count)

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