結果
問題 | No.2837 Flip Triomino |
ユーザー | Shirotsume |
提出日時 | 2024-08-09 22:28:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 128 ms / 2,000 ms |
コード長 | 2,163 bytes |
コンパイル時間 | 135 ms |
コンパイル使用メモリ | 82,444 KB |
実行使用メモリ | 83,072 KB |
最終ジャッジ日時 | 2024-08-09 22:28:50 |
合計ジャッジ時間 | 4,990 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 82 ms
76,032 KB |
testcase_01 | AC | 87 ms
76,160 KB |
testcase_02 | AC | 79 ms
76,416 KB |
testcase_03 | AC | 84 ms
76,032 KB |
testcase_04 | AC | 79 ms
76,160 KB |
testcase_05 | AC | 81 ms
76,288 KB |
testcase_06 | AC | 88 ms
76,160 KB |
testcase_07 | AC | 94 ms
82,048 KB |
testcase_08 | AC | 112 ms
82,944 KB |
testcase_09 | AC | 95 ms
81,920 KB |
testcase_10 | AC | 102 ms
82,048 KB |
testcase_11 | AC | 98 ms
82,048 KB |
testcase_12 | AC | 110 ms
82,816 KB |
testcase_13 | AC | 108 ms
83,072 KB |
testcase_14 | AC | 112 ms
83,068 KB |
testcase_15 | AC | 112 ms
82,816 KB |
testcase_16 | AC | 128 ms
82,944 KB |
testcase_17 | AC | 111 ms
83,032 KB |
testcase_18 | AC | 95 ms
82,008 KB |
testcase_19 | AC | 111 ms
82,944 KB |
testcase_20 | AC | 95 ms
82,048 KB |
testcase_21 | AC | 113 ms
82,944 KB |
testcase_22 | AC | 115 ms
82,944 KB |
testcase_23 | AC | 118 ms
82,944 KB |
testcase_24 | AC | 119 ms
82,816 KB |
testcase_25 | AC | 116 ms
82,944 KB |
testcase_26 | AC | 122 ms
82,988 KB |
testcase_27 | AC | 109 ms
82,432 KB |
testcase_28 | AC | 91 ms
82,048 KB |
testcase_29 | AC | 91 ms
81,856 KB |
testcase_30 | AC | 109 ms
82,368 KB |
testcase_31 | AC | 94 ms
81,920 KB |
testcase_32 | AC | 107 ms
82,368 KB |
testcase_33 | AC | 92 ms
82,176 KB |
testcase_34 | AC | 77 ms
76,544 KB |
testcase_35 | AC | 88 ms
81,536 KB |
testcase_36 | AC | 91 ms
82,176 KB |
ソースコード
import sys, time, random from collections import deque, Counter, defaultdict import logging from logging import debug, error, info, warning logging.basicConfig(level=logging.DEBUG) input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 61 - 1 mod = 998244353 class Combinatorics(): def __init__(self, mod, maxi): self.mod = mod self.maxi = maxi self.facs = [1] * (maxi + 1) self.factinvs = [1] * (maxi + 1) self.invs = [1] * (maxi + 1) for i in range(2, self.maxi + 1): self.facs[i] = ((self.facs[i-1] * i) % self.mod) self.invs[i] = (-self.invs[self.mod % i] * (self.mod // i)) % self.mod self.factinvs[i] = (self.factinvs[i-1] * self.invs[i]) % self.mod def choose(self, n, k): if k < 0 or k > n: return 0 if k == 0 or k == n: return 1 k = min(k, n - k) return (((self.facs[n] * self.factinvs[k]) % self.mod) * self.factinvs[n-k]) % self.mod def perm(self, n, k): return (self.choose(n, k) * self.facs[k]) % self.mod def homop(self, n, k): if n == k == 0: return 1 return self.choose(n + k - 1, k) C = Combinatorics(mod, 10 ** 5) n, m = mi() s = [input() for _ in range(n)] cnt = [0, 0, 0] qu = [0, 0, 0] for i in range(n): for j in range(m): if s[i][j] == 'B': cnt[(i + j) % 3] += 1 elif s[i][j] == '?': qu[(i + j) % 3] += 1 ans = 0 queven = [0, 0, 0] quodd = [0, 0, 0] for i in range(3): for j in range(0, qu[i] + 1, 2): queven[i] += C.choose(qu[i], j) queven[i] %= mod for j in range(1, qu[i] + 1, 2): quodd[i] += C.choose(qu[i], j) quodd[i] %= mod #000 ret = 1 for i in range(3): if cnt[i] % 2: ret *= queven[i] ret %= mod else: ret *= quodd[i] ret %= mod ans += ret ret = 1 for i in range(3): if cnt[i] % 2 == 0: ret *= queven[i] ret %= mod else: ret *= quodd[i] ret %= mod ans += ret print(ans % mod)