結果
問題 |
No.295 hel__world
|
ユーザー |
![]() |
提出日時 | 2025-06-12 16:18:40 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,246 bytes |
コンパイル時間 | 179 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 149,784 KB |
最終ジャッジ日時 | 2025-06-12 16:18:59 |
合計ジャッジ時間 | 4,856 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 WA * 21 |
ソースコード
def compute_runs(s): if not s: return [] runs = [] prev = s[0] runs.append(prev) for c in s[1:]: if c != prev: runs.append(c) prev = c return runs def main(): import sys input = sys.stdin.read().split() idx = 0 S_alpha = list(map(int, input[idx:idx+26])) idx += 26 T = input[idx].strip() idx += 1 runs_T = compute_runs(T) k = len(runs_T) if k == 0: print(0) return count_runs_T = {} for c in runs_T: count_runs_T[c] = count_runs_T.get(c, 0) + 1 possible = True for c in runs_T: if S_alpha[ord(c) - ord('a')] < count_runs_T[c]: possible = False break if not possible: print(0) return product = 1 for c in count_runs_T: m = count_runs_T[c] available = S_alpha[ord(c) - ord('a')] q, r = divmod(available, m) if q == 0: product = 0 break contribution = (pow(q, m - r) * pow(q + 1, r)) if r != 0 else pow(q, m) product *= contribution if product > (1 << 62): print("hel") return print(product) if __name__ == "__main__": main()