結果
| 問題 |
No.603 hel__world (2)
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-16 00:06:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 758 bytes |
| コンパイル時間 | 338 ms |
| コンパイル使用メモリ | 81,852 KB |
| 実行使用メモリ | 140,612 KB |
| 最終ジャッジ日時 | 2025-04-16 00:08:10 |
| 合計ジャッジ時間 | 3,585 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 20 |
ソースコード
MOD = 10**6 + 3
# Read input
S_alpha = list(map(int, input().split()))
T = input().strip()
# Compress T into groups
prev_char = None
groups = []
for c in T:
if c != prev_char:
groups.append(c)
prev_char = c
# Count the number of groups for each character
from collections import defaultdict
group_counts = defaultdict(int)
for c in groups:
group_counts[c] += 1
result = 1
for c in group_counts:
k = group_counts[c]
idx = ord(c) - ord('a')
s = S_alpha[idx]
if s < k:
print(0)
exit()
m = s - k
base, r = divmod(m, k)
a = (base + 2) % MOD
b = (base + 1) % MOD
term = (pow(a, r, MOD) * pow(b, k - r, MOD)) % MOD
result = (result * term) % MOD
print(result)
lam6er