結果
| 問題 | No.603 hel__world (2) | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 16:03:39 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,046 bytes | 
| コンパイル時間 | 434 ms | 
| コンパイル使用メモリ | 82,620 KB | 
| 実行使用メモリ | 161,928 KB | 
| 最終ジャッジ日時 | 2025-06-12 16:03:47 | 
| 合計ジャッジ時間 | 4,015 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 WA * 20 | 
ソースコード
MOD = 10**6 + 3
# Read the S_alpha values for each of the 26 letters
S_alpha = list(map(int, input().split()))
T = input().strip()
# Function to compute the runs in T's minimal form
def compute_runs(s):
    runs = []
    prev = None
    for c in s:
        if c != prev:
            runs.append(c)
            prev = c
    return runs
# Get the runs in T's minimal form
runs = compute_runs(T)
# Count how many runs each character has
from collections import defaultdict
char_runs = defaultdict(int)
for c in runs:
    char_runs[c] += 1
# Calculate the result
result = 1
for char in char_runs:
    k = char_runs[char]
    # Get the index in S_alpha
    idx = ord(char) - ord('a')
    s = S_alpha[idx]
    
    if s < k:
        print(0)
        exit()
    
    E = s - k
    a = E // k
    b = E % k
    
    # Calculate contribution: (a+1)^(k - b) * (a+2)^b mod MOD
    part1 = pow(a + 1, k - b, MOD)
    part2 = pow(a + 2, b, MOD)
    contribution = (part1 * part2) % MOD
    
    result = (result * contribution) % MOD
print(result % MOD)
            
            
            
        