結果
問題 |
No.603 hel__world (2)
|
ユーザー |
![]() |
提出日時 | 2025-04-16 16:20:21 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 758 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 82,072 KB |
実行使用メモリ | 140,500 KB |
最終ジャッジ日時 | 2025-04-16 16:21:48 |
合計ジャッジ時間 | 3,861 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)