結果
| 問題 |
No.295 hel__world
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-16 16:01:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,202 bytes |
| コンパイル時間 | 441 ms |
| コンパイル使用メモリ | 82,464 KB |
| 実行使用メモリ | 158,896 KB |
| 最終ジャッジ日時 | 2025-04-16 16:04:55 |
| 合計ジャッジ時間 | 4,521 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 34 WA * 19 |
ソースコード
import sys
from collections import defaultdict
def main():
S_alpha = list(map(int, sys.stdin.readline().split()))
T = sys.stdin.readline().strip()
if not T:
print(0)
return
# Split T into runs
runs = [T[0]]
for c in T[1:]:
if c != runs[-1]:
runs.append(c)
# Count occurrences of each character in runs
m_c = defaultdict(int)
for c in runs:
m_c[c] += 1
# Check if each character in runs has sufficient count
for c in m_c:
idx = ord(c) - ord('a')
if S_alpha[idx] < m_c[c]:
print(0)
return
product = 1
threshold = (1 << 62)
for c in m_c:
idx = ord(c) - ord('a')
s_total = S_alpha[idx]
m = m_c[c]
s_remaining = s_total - m
if s_remaining < 0:
print(0)
return
q, r = divmod(s_remaining, m)
term = pow(q + 2, r) * pow(q + 1, m - r)
product *= term
if product >= threshold:
print("hel")
return
print("hel" if product >= threshold else product)
if __name__ == "__main__":
main()
lam6er