結果
| 問題 |
No.2837 Flip Triomino
|
| コンテスト | |
| ユーザー |
norikame
|
| 提出日時 | 2024-08-10 01:34:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 1,129 bytes |
| コンパイル時間 | 4,403 ms |
| コンパイル使用メモリ | 253,024 KB |
| 最終ジャッジ日時 | 2025-02-23 22:16:32 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
//
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()
using mint = modint998244353;
const int INF = (int)(1e9);
const ll mod = 998244353LL;
int main() {
int n, m;
cin >> n >> m;
vector<string> s(n);
rep(i, n) cin >> s[i];
vector<int> bcnt(3), qcnt(3);
rep(i, n) rep(j, m) {
if (s[i][j] == 'B') bcnt[(i+j)%3]++;
else if (s[i][j] == '?') qcnt[(i+j)%3]++;
}
int ri = -1;
bool ok = true;
rep(i, 3) if (qcnt[i] == 0) {
if (ri == -1) ri = bcnt[i] % 2;
else if (ri != bcnt[i] % 2) ok = false;
}
if (!ok) {
cout << 0 << endl;
return 0;
}
mint res = 1;
rep(i, 3) if (qcnt[i] > 0) res *= mint(2).pow(qcnt[i]-1);
if (ri == -1) res *= 2;
cout << res.val() << endl;
return 0;
}
norikame