結果

問題 No.295 hel__world
ユーザー convexineqconvexineq
提出日時 2021-01-02 11:29:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,279 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 82,440 KB
実行使用メモリ 110,120 KB
最終ジャッジ日時 2024-04-20 06:07:51
合計ジャッジ時間 9,837 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,616 KB
testcase_01 AC 35 ms
54,092 KB
testcase_02 AC 35 ms
53,668 KB
testcase_03 AC 35 ms
53,556 KB
testcase_04 AC 33 ms
52,932 KB
testcase_05 AC 32 ms
53,660 KB
testcase_06 AC 33 ms
53,340 KB
testcase_07 AC 33 ms
52,620 KB
testcase_08 AC 33 ms
53,700 KB
testcase_09 AC 33 ms
53,636 KB
testcase_10 AC 32 ms
54,528 KB
testcase_11 AC 32 ms
53,076 KB
testcase_12 AC 36 ms
52,888 KB
testcase_13 AC 34 ms
54,136 KB
testcase_14 AC 35 ms
53,856 KB
testcase_15 AC 35 ms
53,748 KB
testcase_16 AC 33 ms
53,744 KB
testcase_17 AC 33 ms
53,572 KB
testcase_18 AC 33 ms
53,568 KB
testcase_19 AC 33 ms
53,408 KB
testcase_20 AC 32 ms
53,628 KB
testcase_21 AC 36 ms
53,672 KB
testcase_22 AC 35 ms
53,204 KB
testcase_23 AC 34 ms
54,200 KB
testcase_24 AC 33 ms
52,960 KB
testcase_25 AC 49 ms
64,848 KB
testcase_26 AC 41 ms
61,720 KB
testcase_27 AC 35 ms
54,012 KB
testcase_28 AC 1,495 ms
76,312 KB
testcase_29 AC 1,535 ms
76,860 KB
testcase_30 AC 36 ms
55,016 KB
testcase_31 WA -
testcase_32 AC 193 ms
109,944 KB
testcase_33 AC 162 ms
109,988 KB
testcase_34 AC 179 ms
110,120 KB
testcase_35 AC 35 ms
53,092 KB
testcase_36 AC 38 ms
53,212 KB
testcase_37 AC 36 ms
53,312 KB
testcase_38 AC 37 ms
54,208 KB
testcase_39 AC 37 ms
53,220 KB
testcase_40 AC 35 ms
53,820 KB
testcase_41 AC 35 ms
53,412 KB
testcase_42 AC 32 ms
53,940 KB
testcase_43 AC 859 ms
76,316 KB
testcase_44 AC 861 ms
76,304 KB
testcase_45 AC 875 ms
76,244 KB
testcase_46 AC 33 ms
53,400 KB
testcase_47 AC 33 ms
53,860 KB
testcase_48 AC 33 ms
54,760 KB
testcase_49 AC 34 ms
53,604 KB
testcase_50 AC 46 ms
66,908 KB
testcase_51 AC 331 ms
76,664 KB
testcase_52 AC 110 ms
76,272 KB
testcase_53 AC 60 ms
78,772 KB
testcase_54 AC 59 ms
78,760 KB
testcase_55 AC 65 ms
79,004 KB
testcase_56 AC 63 ms
78,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

*a, = map(int,input().split())
d = {}
t = input()+"Z"
cnt = 0
now = "A"
for i in t:
    if i == now:
        cnt += 1
    else:
        if now in d: d[now].append(cnt)
        else: d[now] = [cnt]
        now = i
        cnt = 1

V = [0]*26
from heapq import *
for i,ai in enumerate(a):
    s = chr(i+97)
    if s not in d: continue
    v = ai - sum(d[s])
    V[i] = v
    if v < 0:
        print(0)
        exit()

def hel(ans):
    if ans >= MAX:
        print("hel")
        exit()
    

ans = 1
MAX = 1<<62
for i,ai in enumerate(a):
    s = chr(i+97)
    if s not in d: continue
    v = V[i]
    if v==0: continue
    q = [(-(i+1.0),i,i) for i in d[s]] # 倍率、先頭、長さ
    if len(q) == 1:
        for i in range(q[0][-1]):
            ans *= ai-i
            ans //= i+1
            hel(ans)
        continue
    if len(q) == 2:
        if sum(d[s]) == 2:
            x = ai//2
            for aa in [x,ai-x]:
                ans *= aa
                hel(ans)
            continue
    if (v//len(q)) > (MAX+10)**(1/len(q)):
        hel(1<<64)

    if v > 64 and len(q) > 64:
        hel(1<<64)
    heapify(q)
    for _ in range(v):
        __,x,y = heappop(q)
        ans = ans*(y+1)//(y-x+1)
        heappush(q,(-(y+2)/(y+2-x),x,y+1))
        hel(ans)
print(ans)
0