結果

問題 No.1846 Good Binary Matrix
ユーザー asumo0729asumo0729
提出日時 2022-02-18 22:45:59
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,631 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 516,224 KB
最終ジャッジ日時 2023-09-11 19:47:00
合計ジャッジ時間 10,637 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 366 ms
257,612 KB
testcase_02 AC 373 ms
257,524 KB
testcase_03 AC 369 ms
257,316 KB
testcase_04 AC 368 ms
257,428 KB
testcase_05 AC 370 ms
258,632 KB
testcase_06 AC 366 ms
258,624 KB
testcase_07 AC 370 ms
257,764 KB
testcase_08 AC 364 ms
257,556 KB
testcase_09 AC 369 ms
257,596 KB
testcase_10 AC 370 ms
257,800 KB
testcase_11 AC 367 ms
257,296 KB
testcase_12 AC 375 ms
257,568 KB
testcase_13 AC 370 ms
257,384 KB
testcase_14 AC 371 ms
257,608 KB
testcase_15 AC 376 ms
257,664 KB
testcase_16 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from operator import itemgetter
from collections import defaultdict, deque
import heapq
import bisect
import math
import itertools
import copy

stdin=sys.stdin
sys.setrecursionlimit(10 ** 8)

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()
Yp=lambda:print('Yes')
Np=lambda:print('No')
inf = 1 << 60
inf = float('inf')
mod = 10 ** 9 + 7
#mod = 998244353
eps = 1e-9
sortkey1 = itemgetter(0)
sortkey2 = lambda x: (x[0], x[1])

class Comb():
    def __init__(self, N, mod):
        self.N = N
        self.mod = mod
        self.fa = self.fa_fainv()[0]
        self.fainv = self.fa_fainv()[1]

    def fa_fainv(self):
        fa = [1]
        for i in range(1, self.N + 1):
            fa.append(fa[-1] * i % self.mod)

        fainv = [pow(fa[-1],self.mod - 2,self.mod)]
        for i in range(1, self.N + 1)[::-1]:
            fainv.append(fainv[-1] * i % self.mod)
        fainv = fainv[::-1]

        return fa, fainv

    def aCb(self, a, b):
        if b < 0 or a < b: 
            return 0
        return self.fa[a] * self.fainv[a - b] * self.fainv[b] % self.mod

    def aPb(self, a, b):
        if b < 0 or a < b: 
            return 0
        return self.fa[a] * self.fainv[a - b]

###############################################################

H, W = lp()
comb = Comb(10 ** 6 + 2, mod)
ans = 0
s = -1
for i in range(H + 1):
    s *= -1
    p = pow(2, H - i, mod)
    p = pow(p, mod - 2, mod)
    C = comb.aCb(H, i) * pow(2, H * W - W * i, mod)

    r = pow(1 - p, W, mod)
    q = s * C * r
    ans += q
    ans %= mod

print(ans)
0