結果
| 問題 | No.603 hel__world (2) | 
| コンテスト | |
| ユーザー |  lam6er | 
| 提出日時 | 2025-04-16 16:18:36 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 888 bytes | 
| コンパイル時間 | 373 ms | 
| コンパイル使用メモリ | 81,464 KB | 
| 実行使用メモリ | 140,292 KB | 
| 最終ジャッジ日時 | 2025-04-16 16:20:09 | 
| 合計ジャッジ時間 | 3,950 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 WA * 20 | 
ソースコード
MOD = 10**6 + 3
# Read input
s_alpha = list(map(int, input().split()))
t = input().strip()
# Process T into its connected components
t_comp = []
prev_char = None
for char in t:
    if char != prev_char:
        t_comp.append(char)
        prev_char = char
# Count the frequency of each character in t_comp
from collections import defaultdict
char_count = defaultdict(int)
for c in t_comp:
    char_count[c] += 1
# Check if any character's count exceeds the available S_alpha
for c in char_count:
    idx = ord(c) - ord('a')
    if s_alpha[idx] < char_count[c]:
        print(0)
        exit()
# Calculate the product of maximum possible terms
result = 1
for c in char_count:
    idx = ord(c) - ord('a')
    k = char_count[c]
    s = s_alpha[idx]
    m = s // k
    r = s % k
    term = (pow(m + 1, r, MOD) * pow(m, k - r, MOD)) % MOD
    result = (result * term) % MOD
print(result)
            
            
            
        