結果
| 問題 |
No.1702 count good string
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 20:20:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 233 ms / 2,000 ms |
| コード長 | 614 bytes |
| コンパイル時間 | 199 ms |
| コンパイル使用メモリ | 82,308 KB |
| 実行使用メモリ | 76,480 KB |
| 最終ジャッジ日時 | 2025-03-20 20:21:15 |
| 合計ジャッジ時間 | 6,676 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 47 |
ソースコード
MOD = 10**9 + 7
n = int(input())
s = input().strip()
base = 'yukicoder'
targets = [base]
for i in range(len(base)):
temp = list(base)
temp[i] = '?'
targets.append(''.join(temp))
result = 0
for target in targets:
dp = [0] * (len(base) + 1)
dp[0] = 1 # Initial state: 1 way to form an empty subsequence
for c in s:
# Iterate backwards to avoid overwriting the dp values we need to use
for j in reversed(range(len(base))):
if c == target[j]:
dp[j+1] = (dp[j+1] + dp[j]) % MOD
result = (result + dp[len(base)]) % MOD
print(result)
lam6er