結果
| 問題 |
No.603 hel__world (2)
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 20:42:54 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 899 bytes |
| コンパイル時間 | 143 ms |
| コンパイル使用メモリ | 82,556 KB |
| 実行使用メモリ | 141,208 KB |
| 最終ジャッジ日時 | 2025-03-20 20:43:05 |
| 合計ジャッジ時間 | 3,785 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 20 |
ソースコード
mod = 10**6 + 3
# Read S_counts
s_counts = list(map(int, input().split()))
t = input().strip()
# Generate T_compact
t_compact = []
prev_char = None
for c in t:
if c != prev_char:
t_compact.append(c)
prev_char = c
k_dict = {}
for c in t_compact:
if c in k_dict:
k_dict[c] += 1
else:
k_dict[c] = 1
# Check validity: each c in k_dict must have S_counts >= k_dict[c]
valid = True
for c in k_dict:
idx = ord(c) - ord('a')
if s_counts[idx] < k_dict[c]:
valid = False
break
if not valid:
print(0)
exit()
# Calculate the maximum product
ans = 1
for c in k_dict:
k = k_dict[c]
idx = ord(c) - ord('a')
s_total = s_counts[idx]
m = s_total - k # m >=0
d, r = divmod(m, k)
part1 = pow(d + 1, k - r, mod)
part2 = pow(d + 2, r, mod)
ans = (ans * part1) % mod
ans = (ans * part2) % mod
print(ans)
lam6er