結果
問題 |
No.295 hel__world
|
ユーザー |
![]() |
提出日時 | 2025-06-12 16:17:02 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,387 bytes |
コンパイル時間 | 199 ms |
コンパイル使用メモリ | 82,232 KB |
実行使用メモリ | 172,800 KB |
最終ジャッジ日時 | 2025-06-12 16:18:12 |
合計ジャッジ時間 | 4,873 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 34 WA * 19 |
ソースコード
import sys from collections import defaultdict def main(): # Read the 26 S_alpha values s_alpha = list(map(int, sys.stdin.readline().split())) # Read T T = sys.stdin.readline().strip() # Process T to get the run sequence R R = [] prev = None for c in T: if c != prev: R.append(c) prev = c K = len(R) # For each character in R, collect the indices of their occurrences indices = defaultdict(list) for i, c in enumerate(R): indices[c].append(i) # Initialize the list to hold the length of each run in S l = [0] * K # Process each character's runs for c in indices: m_c = len(indices[c]) # Get the available count for this character in S sa = s_alpha[ord(c) - ord('a')] if sa < m_c: print(0) return s_c = sa q = s_c // m_c r = s_c % m_c # Assign q+1 to the first r positions, q to the rest for idx in indices[c][:r]: l[idx] = q + 1 for idx in indices[c][r:]: l[idx] = q # Compute the product of all run lengths mod = 2 ** 62 product = 1 for run_length in l: product *= run_length if product >= mod: print("hel") return print(product) if __name__ == "__main__": main()