結果

問題 No.295 hel__world
ユーザー mkawa2mkawa2
提出日時 2021-03-16 12:25:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,622 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 13,056 KB
実行使用メモリ 37,772 KB
最終ジャッジ日時 2024-04-25 11:31:50
合計ジャッジ時間 7,324 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,880 KB
testcase_01 RE -
testcase_02 AC 29 ms
10,752 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 RE -
testcase_05 AC 30 ms
10,880 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 30 ms
11,008 KB
testcase_12 AC 30 ms
10,880 KB
testcase_13 AC 31 ms
11,008 KB
testcase_14 AC 27 ms
11,008 KB
testcase_15 AC 29 ms
10,880 KB
testcase_16 WA -
testcase_17 AC 31 ms
11,008 KB
testcase_18 AC 29 ms
11,008 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 AC 29 ms
10,880 KB
testcase_25 RE -
testcase_26 AC 34 ms
10,880 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 31 ms
10,880 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 767 ms
37,772 KB
testcase_33 AC 792 ms
37,512 KB
testcase_34 AC 818 ms
37,644 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 30 ms
11,008 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 31 ms
11,136 KB
testcase_43 AC 32 ms
10,880 KB
testcase_44 AC 30 ms
10,880 KB
testcase_45 AC 29 ms
11,008 KB
testcase_46 AC 31 ms
11,008 KB
testcase_47 AC 31 ms
10,880 KB
testcase_48 AC 30 ms
11,008 KB
testcase_49 AC 29 ms
10,880 KB
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 AC 83 ms
12,928 KB
testcase_54 AC 83 ms
12,928 KB
testcase_55 AC 82 ms
12,928 KB
testcase_56 AC 84 ms
13,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

from heapq import *

def RLE(s):
    cc=[]
    ww=[]
    pc=s[0]
    w=0
    for c in s:
        if c==pc:w+=1
        else:
            cc.append(pc)
            ww.append(w)
            w=1
            pc=c
    cc.append(pc)
    ww.append(w)
    return cc,ww

lim=1<<62
aa=LI()
s=BI()

cc,ll=RLE(s)

cnt=[[] for _ in range(26)]
for c,l in zip(cc,ll):
    cnt[c-97].append(l)
# print(cnt)

ans=1
for i,(a,cc) in enumerate(zip(aa,cnt)):
    if not cc:continue
    s=sum(cc)
    if a<s:
        print(0)
        exit()
    aa[i]=a-s

for i, (a, cc) in enumerate(zip(aa, cnt)):
    if a>1000000:
        print("hel")
        exit()

    hp=[]
    cur=1
    for c in cc:
        heappush(hp,(-(c+1)/(c-c+1),c,c))
        cur=1
    for _ in range(a):
        m,n,r=heappop(hp)
        cur*=-m
        heappush(hp,(-(n+2)/(n-r+2),n+1,r))
    ans*=cur
    if ans>=lim:
        print("hel")
        exit()

print(round(ans))
0