結果

問題 No.2013 Can we meet?
ユーザー Kiri8128Kiri8128
提出日時 2022-04-16 14:10:19
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 894 bytes
コンパイル時間 1,025 ms
コンパイル使用メモリ 86,824 KB
実行使用メモリ 276,256 KB
最終ジャッジ日時 2023-09-18 05:33:20
合計ジャッジ時間 9,482 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,416 KB
testcase_01 AC 87 ms
71,364 KB
testcase_02 AC 86 ms
71,508 KB
testcase_03 AC 100 ms
77,356 KB
testcase_04 AC 86 ms
71,424 KB
testcase_05 AC 86 ms
71,560 KB
testcase_06 AC 89 ms
71,600 KB
testcase_07 AC 88 ms
71,688 KB
testcase_08 AC 98 ms
76,980 KB
testcase_09 AC 99 ms
77,340 KB
testcase_10 AC 97 ms
77,212 KB
testcase_11 AC 97 ms
77,340 KB
testcase_12 AC 100 ms
77,628 KB
testcase_13 AC 101 ms
77,536 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
P = 998244353
def naive():
    x = abs(x1 - x2)
    y = abs(y1 - y2)

    D = defaultdict(int, {(x, y): 1})
    ANS = []
    for loop in range(n):
        for _ in range(2):
            nD = defaultdict(int)
            for k, v in D.items():
                xx, yy = k
                for nx, ny, prob in ((xx + 1, yy, alpha), (xx - 1, yy, alpha), (xx, yy + 1, beta), (xx, yy - 1, beta)):
                    nxy = (nx, ny)
                    nD[nxy] = (nD[nxy] + v * prob) % P
            D = nD
        ANS.append(D[(0, 0)])
        D[(0, 0)] = 0
    ans = 0
    for i in range(n):
        ans = (ans + ANS[i] * A[i]) % P
    return ans

n = int(input())
x1, y1, x2, y2 = map(int, input().split())
a, b = map(int, input().split())
iv = pow(2 * (a + b), P - 2, P)
alpha = a * iv % P
beta = b * iv % P

A = [int(a) for a in input().split()]
print(naive())
0