結果
問題 | No.1547 [Cherry 2nd Tune *] 偶然の勝利の確率 |
ユーザー | mkawa2 |
提出日時 | 2021-06-12 00:06:15 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,228 bytes |
コンパイル時間 | 410 ms |
コンパイル使用メモリ | 13,056 KB |
実行使用メモリ | 50,148 KB |
最終ジャッジ日時 | 2024-05-08 20:52:54 |
合計ジャッジ時間 | 23,814 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 527 ms
50,148 KB |
testcase_01 | AC | 531 ms
44,136 KB |
testcase_02 | AC | 642 ms
44,260 KB |
testcase_03 | AC | 524 ms
44,012 KB |
testcase_04 | AC | 528 ms
44,140 KB |
testcase_05 | AC | 526 ms
43,980 KB |
testcase_06 | AC | 525 ms
44,264 KB |
testcase_07 | AC | 523 ms
44,396 KB |
testcase_08 | AC | 526 ms
44,268 KB |
testcase_09 | AC | 532 ms
44,008 KB |
testcase_10 | AC | 530 ms
44,136 KB |
testcase_11 | AC | 532 ms
44,520 KB |
testcase_12 | AC | 528 ms
44,392 KB |
testcase_13 | AC | 1,179 ms
44,132 KB |
testcase_14 | AC | 958 ms
44,264 KB |
testcase_15 | AC | 700 ms
44,392 KB |
testcase_16 | AC | 807 ms
44,008 KB |
testcase_17 | AC | 806 ms
44,392 KB |
testcase_18 | AC | 780 ms
44,268 KB |
testcase_19 | AC | 599 ms
44,008 KB |
testcase_20 | TLE | - |
testcase_21 | AC | 695 ms
44,264 KB |
testcase_22 | AC | 522 ms
44,392 KB |
testcase_23 | TLE | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
ソースコード
import sys sys.setrecursionlimit(200005) 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 import numpy as np from time import time # def dot(aa,bb): # return [[sum(a*b%md for a,b in zip(row,col))%md for col in zip(*bb)] for row in aa] ma, na, s = LI() mb, nb, t = LI() K = II() tt=[] tt.append(time()) s += t s, t = t, s pa = ma*pow(na, md-2, md) pb = mb*pow(nb, md-2, md) # print(pa,pb) dtop = [0]*(t+1) now = (1-pa)%md for i in range(t+1): dtop[i] = now now = now*pa%md pp0=[[0]*(t+1) for _ in range(t+1)] for i in range(1,t): p=1 d=0 for j in range(i,t): pp0[i][j]=dtop[d] p-=dtop[d] d+=1 pp0[i][t]=p%md # p2D(pp0) tt.append(time()) dtop = [0]*(t+1) now = (1-pb)%md for i in range(t+1): dtop[i] = now now = now*pb%md pp1=[[0]*(t+1) for _ in range(t+1)] for i in range(t-1,0,-1): p=1 d=0 for j in range(i,0,-1): pp1[i][j]=dtop[d] p-=dtop[d] d+=1 pp1[i][0]=p%md tt.append(time()) base=np.zeros((t+1,t+1),dtype=object) # base=[[0]*(t+1) for _ in range(t+1)] for i in range(1,t): for j in range(i,t): for k in range(j+1): base[k][i]=(base[k][i]+pp0[i][j]*pp1[j][k])%md for i in range(1,t): base[t][i]=pp0[i][t] base[0][0]=1 base[t][t]=1 # p2D(base) tt.append(time()) # cc=[[0]*(t+1) for _ in range(t+1)] # for i in range(t+1):cc[i][i]=1 cc=np.eye(t+1,dtype=object) while K: if K&1:cc=np.dot(cc,base)%md base=np.dot(base,base)%md K>>=1 tt.append(time()) # print(s,t) # p2D(cc) print(cc[t][s]) print(cc[0][s]) # t0=tt[0] # tt=[t-t0 for t in tt] # print(*tt)