結果
| 問題 | No.295 hel__world | 
| コンテスト | |
| ユーザー |  lam6er | 
| 提出日時 | 2025-04-15 22:48:37 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 978 bytes | 
| コンパイル時間 | 164 ms | 
| コンパイル使用メモリ | 81,628 KB | 
| 実行使用メモリ | 155,296 KB | 
| 最終ジャッジ日時 | 2025-04-15 22:50:41 | 
| 合計ジャッジ時間 | 4,354 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 34 WA * 19 | 
ソースコード
from collections import defaultdict
def main():
    S_counts = list(map(int, input().split()))
    T = input().strip()
    
    # Process T into runs
    R_T = []
    prev_char = None
    for c in T:
        if c != prev_char:
            R_T.append(c)
            prev_char = c
    
    # Count frequency of each character in R_T
    freq = defaultdict(int)
    for c in R_T:
        freq[c] += 1
    
    # Check if any character's frequency exceeds S's count
    for c in freq:
        idx = ord(c) - ord('a')
        if freq[c] > S_counts[idx]:
            print(0)
            return
    
    # Calculate the product
    product = 1
    for c in freq:
        idx = ord(c) - ord('a')
        m = freq[c]
        s = S_counts[idx]
        q, r = divmod(s, m)
        term = ( (q + 1) ** r ) * ( q ** (m - r) )
        product *= term
        if product >= (1 << 62):
            print("hel")
            return
    
    print(product)
if __name__ == "__main__":
    main()
            
            
            
        