結果
| 問題 | No.603 hel__world (2) | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 19:39:59 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,252 bytes | 
| コンパイル時間 | 173 ms | 
| コンパイル使用メモリ | 81,840 KB | 
| 実行使用メモリ | 142,108 KB | 
| 最終ジャッジ日時 | 2025-06-12 19:40:16 | 
| 合計ジャッジ時間 | 3,773 ms | 
| ジャッジサーバーID (参考情報) | judge4 / 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()
# Handle empty T (though problem states T is at least length 1)
if not T:
    print(0)
    exit()
# Compress T by removing consecutive duplicates
t_compressed = [T[0]]
for c in T[1:]:
    if c != t_compressed[-1]:
        t_compressed.append(c)
# Check each character in compressed T has at least 1 available
for c in t_compressed:
    idx = ord(c) - ord('a')
    if s_alpha[idx] < 1:
        print(0)
        exit()
# Count occurrences of each character in compressed T
from collections import defaultdict
char_counts = defaultdict(int)
for c in t_compressed:
    char_counts[c] += 1
# Check if each character has enough total occurrences for its groups
for c in char_counts:
    idx = ord(c) - ord('a')
    required = char_counts[c]
    if s_alpha[idx] < required:
        print(0)
        exit()
# Calculate the product of contributions for each character
result = 1
for c in char_counts:
    cnt = char_counts[c]
    idx = ord(c) - ord('a')
    s = s_alpha[idx]
    q, r = divmod(s, cnt)
    part1 = pow(q + 1, r, MOD)
    part2 = pow(q, cnt - r, MOD)
    contribution = (part1 * part2) % MOD
    result = (result * contribution) % MOD
print(result)
            
            
            
        