結果

問題 No.1655 123 Swaps
ユーザー Kiri8128Kiri8128
提出日時 2021-06-25 00:00:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,842 ms / 2,000 ms
コード長 2,838 bytes
コンパイル時間 999 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 227,340 KB
最終ジャッジ日時 2024-10-14 02:16:10
合計ジャッジ時間 33,378 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
68,608 KB
testcase_01 AC 65 ms
68,608 KB
testcase_02 AC 91 ms
80,256 KB
testcase_03 AC 64 ms
68,608 KB
testcase_04 AC 63 ms
68,608 KB
testcase_05 AC 64 ms
68,224 KB
testcase_06 AC 63 ms
68,608 KB
testcase_07 AC 64 ms
68,480 KB
testcase_08 AC 63 ms
68,480 KB
testcase_09 AC 65 ms
69,504 KB
testcase_10 AC 84 ms
76,672 KB
testcase_11 AC 67 ms
70,272 KB
testcase_12 AC 87 ms
78,080 KB
testcase_13 AC 62 ms
68,480 KB
testcase_14 AC 63 ms
68,480 KB
testcase_15 AC 1,832 ms
218,512 KB
testcase_16 AC 1,806 ms
218,652 KB
testcase_17 AC 1,842 ms
219,864 KB
testcase_18 AC 1,830 ms
219,840 KB
testcase_19 AC 1,835 ms
219,752 KB
testcase_20 AC 1,810 ms
218,880 KB
testcase_21 AC 1,783 ms
218,640 KB
testcase_22 AC 1,797 ms
220,120 KB
testcase_23 AC 1,807 ms
220,120 KB
testcase_24 AC 1,793 ms
220,080 KB
testcase_25 AC 1,811 ms
220,252 KB
testcase_26 AC 1,771 ms
218,568 KB
testcase_27 AC 919 ms
144,812 KB
testcase_28 AC 916 ms
142,556 KB
testcase_29 AC 1,786 ms
227,340 KB
testcase_30 AC 1,785 ms
225,736 KB
testcase_31 AC 928 ms
142,128 KB
testcase_32 AC 64 ms
68,480 KB
testcase_33 AC 63 ms
68,352 KB
testcase_34 AC 64 ms
68,480 KB
testcase_35 AC 64 ms
68,480 KB
testcase_36 AC 110 ms
94,720 KB
testcase_37 AC 110 ms
95,360 KB
testcase_38 AC 133 ms
101,888 KB
testcase_39 AC 156 ms
101,760 KB
testcase_40 AC 1,744 ms
218,376 KB
testcase_41 AC 64 ms
68,224 KB
testcase_42 AC 63 ms
68,608 KB
testcase_43 AC 64 ms
68,608 KB
testcase_44 AC 63 ms
68,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p, g, ig = 924844033, 5, 554906420
W = [pow(g, (p - 1) >> i, p) for i in range(24)]
iW = [pow(ig, (p - 1) >> i, p) for i in range(24)]

def convolve(a, b):
    def fft(f):
        for l in range(k, 0, -1):
            d = 1 << l - 1
            U = [1]
            for i in range(d):
                U.append(U[-1] * W[l] % p)

            for i in range(1 << k - l):
                for j in range(d):
                    s = i * 2 * d + j
                    t = s + d
                    f[s], f[t] = (f[s] + f[t]) % p, U[j] * (f[s] - f[t]) % p

    def ifft(f):
        for l in range(1, k + 1):
            d = 1 << l - 1
            U = [1]
            for i in range(d):
                U.append(U[-1] * iW[l] % p)

            for i in range(1 << k - l):
                for j in range(d):
                    s = i * 2 * d + j
                    t = s + d
                    f[s], f[t] = (f[s] + f[t] * U[j]) % p, (f[s] - f[t] * U[j]) % p

    n0 = len(a) + len(b) - 1
    if len(a) < 50 or len(b) < 50:
        ret = [0] * n0
        if len(a) > len(b): a, b = b, a
        for i, aa in enumerate(a):
            for j, bb in enumerate(b):
                ret[i+j] = (ret[i+j] + aa * bb) % p
        return ret
    
    k = (n0).bit_length()
    n = 1 << k
    a = a + [0] * (n - len(a))
    b = b + [0] * (n - len(b))
    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    for i in range(n0):
        a[i] = a[i] * invn % p
    del a[n0:]
    return a

P = 924844033
nn = 600600

fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P

def calc(a, b, c):
    M = a + b + c
    if M % 2: return 0
    M //= 2
    i3 = pow(3, P - 2, P)
    re = 0
    A = [[0] * (a + 1) for _ in range(3)]
    B = [[0] * (b + 1) for _ in range(3)]
    
    for i in range(a + 1):
        A[(2*i-a)%3][i] = fainv[i] * fainv[a-i] % P
    for i in range(b + 1):
        B[(b-2*i)%3][i] = fainv[i] * fainv[b-i] % P
    
    AB = [[0] * (a + b + 1) for _ in range(2)]
    for k1 in range(3):
        for k2 in range(3):
            k = (k1 + k2) % 3
            if k == 2: continue
            ab = AB[k]
            for i, x in enumerate(convolve(A[k1], B[k2])):
                ab[i] = (ab[i] + x) % P
    
    RE = [0] * 2
    for k, ab in enumerate(AB):
        for i, x in enumerate(ab):
            if i > M: continue
            j = M - a - b + i
            if j < 0: continue
            RE[k] = (RE[k] + x * fainv[M-i] * fainv[j]) % P
    
    re = RE[0] - RE[1]
    re = re * fa[M] ** 2 % P * 2 * i3 % P
    re = (re + fa[M*2] * fainv[a] * fainv[b] * fainv[c] * i3) % P
    return re

a, b, c = map(int, input().split())
print(calc(a, b, c))


0