結果

問題 No.295 hel__world
ユーザー mkawa2mkawa2
提出日時 2021-03-16 13:03:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,885 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-25 11:56:53
合計ジャッジ時間 12,526 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.readline().rstrip().encode()
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
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 not cc or a==0:continue

    if a>10000000 and sum(cc)>2:
        print("hel")
        exit()

    if sum(cc)==1:
        cur=a+1
    elif sum(cc)==2:
        a += 2
        if len(cc)==1:
            cur=a*(a-1)//2
        else:
            cur=(a//2)*(a-a//2)
    else:
        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=round(-m*cur)
            heappush(hp,(-(n+2)/(n-r+2),n+1,r))
    ans*=cur
    if ans>=lim:
        print("hel")
        exit()

print(ans)
0