結果
問題 |
No.603 hel__world (2)
|
ユーザー |
![]() |
提出日時 | 2025-06-12 19:42:00 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,033 bytes |
コンパイル時間 | 266 ms |
コンパイル使用メモリ | 82,132 KB |
実行使用メモリ | 163,468 KB |
最終ジャッジ日時 | 2025-06-12 19:42:06 |
合計ジャッジ時間 | 5,386 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 20 |
ソースコード
MOD = 10**6 + 3 def compress(s): if not s: return [] res = [s[0]] for c in s[1:]: if c != res[-1]: res.append(c) return res # Read input S_counts = list(map(int, input().split())) T = input().strip() ct = compress(T) if not ct: print(0) exit() from collections import defaultdict m = defaultdict(int) for c in ct: m[c] += 1 # Check if all required characters have at least the necessary count valid = True for c in m: idx = ord(c) - ord('a') if S_counts[idx] < m[c]: valid = False break if not valid: print(0) exit() # Calculate the product count = defaultdict(int) result = 1 for c in ct: alpha = c idx = ord(alpha) - ord('a') m_alpha = m[alpha] R = S_counts[idx] - m_alpha base = R // m_alpha rem = R % m_alpha current_count = count[alpha] + 1 count[alpha] = current_count add = 1 if current_count <= rem else 0 current_val = 1 + base + add result = (result * current_val) % MOD print(result)