結果
| 問題 |
No.603 hel__world (2)
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:33:10 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,021 bytes |
| コンパイル時間 | 188 ms |
| コンパイル使用メモリ | 82,348 KB |
| 実行使用メモリ | 141,172 KB |
| 最終ジャッジ日時 | 2025-03-31 17:33:44 |
| 合計ジャッジ時間 | 4,202 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 20 |
ソースコード
MOD = 10**6 + 3
# Read input
s_counts = list(map(int, input().split()))
s = {chr(ord('a') + i): s_counts[i] for i in range(26)}
T = input().strip()
# Process T to get runs and count occurrences per character
Run_T = []
prev_char = None
for c in T:
if c != prev_char:
Run_T.append(c)
prev_char = c
from collections import defaultdict
count_runs = defaultdict(int)
for c in Run_T:
count_runs[c] += 1
# Check if any character in T's runs has insufficient count in S
for c, m in count_runs.items():
if s[c] < m:
print(0)
exit()
result = 1
# Calculate contribution for each character in the runs
for c, m in count_runs.items():
sc = s[c]
k = sc - m # Remaining characters after accounting for minimum needed per run
base = k // m
rem = k % m
a = (base + 2) % MOD
b = (base + 1) % MOD
# Compute (a^rem * b^(m - rem)) mod MOD
term = (pow(a, rem, MOD) * pow(b, m - rem, MOD)) % MOD
result = (result * term) % MOD
print(result)
lam6er