結果
問題 |
No.603 hel__world (2)
|
ユーザー |
![]() |
提出日時 | 2025-06-12 12:38:55 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,009 bytes |
コンパイル時間 | 451 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 141,080 KB |
最終ジャッジ日時 | 2025-06-12 12:39:01 |
合計ジャッジ時間 | 5,576 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 20 |
ソースコード
MOD = 10**6 + 3 # Read input S_counts = list(map(int, input().split())) T = input().strip() # Create T_comp by removing consecutive duplicates prev_char = None T_comp = [] for c in T: if c != prev_char: T_comp.append(c) prev_char = c # Count occurrences of each character in T_comp from collections import defaultdict char_counts = defaultdict(int) for c in T_comp: char_counts[c] += 1 # Check if all characters in T_comp have sufficient counts in S result = 1 for char in char_counts: required = char_counts[char] available = S_counts[ord(char) - ord('a')] if available < required: print(0) exit() k = available - required base, remainder = divmod(k, required) # Calculate contribution (base+1)^(required - remainder) * (base+2)^remainder mod MOD part1 = pow(base + 1, required - remainder, MOD) part2 = pow(base + 2, remainder, MOD) contribution = (part1 * part2) % MOD result = (result * contribution) % MOD print(result)