結果

問題 No.1845 Long Substrings
ユーザー chineristACchineristAC
提出日時 2022-02-18 22:38:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 293 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 86,584 KB
実行使用メモリ 115,432 KB
最終ジャッジ日時 2023-09-11 19:40:03
合計ジャッジ時間 8,309 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 274 ms
115,244 KB
testcase_01 AC 253 ms
107,976 KB
testcase_02 AC 293 ms
115,396 KB
testcase_03 AC 273 ms
115,432 KB
testcase_04 AC 253 ms
108,104 KB
testcase_05 AC 246 ms
107,716 KB
testcase_06 AC 267 ms
113,780 KB
testcase_07 AC 257 ms
108,064 KB
testcase_08 AC 267 ms
113,812 KB
testcase_09 AC 269 ms
113,776 KB
testcase_10 AC 247 ms
107,856 KB
testcase_11 AC 259 ms
110,048 KB
testcase_12 AC 258 ms
110,372 KB
testcase_13 AC 248 ms
107,776 KB
testcase_14 AC 267 ms
115,028 KB
testcase_15 AC 123 ms
79,488 KB
testcase_16 AC 118 ms
79,480 KB
testcase_17 AC 120 ms
79,656 KB
testcase_18 AC 121 ms
79,504 KB
testcase_19 AC 122 ms
79,920 KB
testcase_20 AC 113 ms
74,564 KB
testcase_21 AC 110 ms
74,344 KB
testcase_22 AC 114 ms
74,584 KB
testcase_23 AC 109 ms
74,280 KB
testcase_24 AC 110 ms
74,608 KB
testcase_25 AC 109 ms
74,268 KB
testcase_26 AC 109 ms
74,340 KB
testcase_27 AC 113 ms
74,300 KB
testcase_28 AC 110 ms
74,572 KB
testcase_29 AC 111 ms
74,092 KB
testcase_30 AC 111 ms
74,524 KB
testcase_31 AC 112 ms
74,296 KB
testcase_32 AC 113 ms
74,560 KB
testcase_33 AC 114 ms
74,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

mod = 10**9 + 7

N = int(input())
A = li()
S = input()
S = [ord(s)-ord("a") for s in S]

dp = [0 for i in range(N)]
memo = [0 for i in range(26)]
for i in range(N):
    dp[i] = A[i]
    for j in range(26):
        if j!=S[i]:
            dp[i] += A[i] * memo[j]
        else:
            dp[i] += memo[j]
        dp[i] %= mod
    dp[i] %= mod
    memo[S[i]] = dp[i]

res = sum(memo) % mod
print(res)
0