結果

問題 No.295 hel__world
ユーザー convexineqconvexineq
提出日時 2021-01-02 11:35:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,247 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 82,540 KB
実行使用メモリ 109,724 KB
最終ジャッジ日時 2024-04-20 06:16:05
合計ジャッジ時間 19,162 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,956 KB
testcase_01 AC 40 ms
52,916 KB
testcase_02 AC 41 ms
54,248 KB
testcase_03 AC 40 ms
53,808 KB
testcase_04 AC 41 ms
53,688 KB
testcase_05 AC 40 ms
53,868 KB
testcase_06 AC 39 ms
53,436 KB
testcase_07 AC 41 ms
52,756 KB
testcase_08 AC 40 ms
53,356 KB
testcase_09 AC 40 ms
53,816 KB
testcase_10 AC 40 ms
53,012 KB
testcase_11 AC 39 ms
53,212 KB
testcase_12 AC 40 ms
54,216 KB
testcase_13 AC 42 ms
54,192 KB
testcase_14 AC 41 ms
53,808 KB
testcase_15 AC 40 ms
53,076 KB
testcase_16 AC 39 ms
53,020 KB
testcase_17 AC 40 ms
53,728 KB
testcase_18 AC 41 ms
53,256 KB
testcase_19 AC 39 ms
52,884 KB
testcase_20 AC 39 ms
52,960 KB
testcase_21 AC 40 ms
53,760 KB
testcase_22 AC 39 ms
53,060 KB
testcase_23 AC 40 ms
53,648 KB
testcase_24 AC 40 ms
52,652 KB
testcase_25 AC 56 ms
64,800 KB
testcase_26 AC 47 ms
60,224 KB
testcase_27 AC 40 ms
53,832 KB
testcase_28 AC 1,905 ms
76,040 KB
testcase_29 AC 1,942 ms
76,336 KB
testcase_30 AC 41 ms
53,976 KB
testcase_31 WA -
testcase_32 AC 212 ms
109,724 KB
testcase_33 AC 184 ms
109,724 KB
testcase_34 AC 205 ms
109,692 KB
testcase_35 AC 39 ms
53,880 KB
testcase_36 AC 40 ms
53,048 KB
testcase_37 AC 40 ms
53,284 KB
testcase_38 AC 40 ms
53,460 KB
testcase_39 AC 39 ms
53,988 KB
testcase_40 AC 40 ms
53,320 KB
testcase_41 AC 40 ms
52,736 KB
testcase_42 AC 40 ms
53,348 KB
testcase_43 AC 1,074 ms
75,964 KB
testcase_44 AC 1,081 ms
76,060 KB
testcase_45 AC 1,074 ms
76,356 KB
testcase_46 AC 1,077 ms
76,156 KB
testcase_47 AC 1,943 ms
75,996 KB
testcase_48 AC 1,964 ms
76,276 KB
testcase_49 AC 1,945 ms
76,388 KB
testcase_50 AC 58 ms
67,404 KB
testcase_51 AC 415 ms
76,072 KB
testcase_52 AC 136 ms
75,960 KB
testcase_53 AC 71 ms
78,984 KB
testcase_54 AC 71 ms
78,760 KB
testcase_55 AC 74 ms
78,888 KB
testcase_56 AC 74 ms
78,864 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 == sum(d[s]):
        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