結果
問題 |
No.2837 Flip Triomino
|
ユーザー |
👑 ![]() |
提出日時 | 2024-08-09 23:24:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 1,157 bytes |
コンパイル時間 | 820 ms |
コンパイル使用メモリ | 81,216 KB |
最終ジャッジ日時 | 2025-02-23 22:11:16 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#ifdef NACHIA #define _GLIBCXX_DEBUG #else #define NDEBUG #endif #include <iostream> #include <string> #include <vector> #include <algorithm> using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<int(n); i++) const i64 INF = 1001001001001001001; template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; } template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; } #include <atcoder/modint> #include <atcoder/dsu> using Modint = atcoder::static_modint<998244353>; using namespace std; void testcase(){ int H, W; cin >> H >> W; vector<string> A(H); rep(y,H) cin >> A[y]; int k[3] = {}; int s[3] = {}; rep(y,H) rep(x,W){ int q = (y+x)%3; if(A[y][x] == '?') k[q]++; if(A[y][x] == 'B') s[q] ^= 1; } Modint ans = 1; int q = -1; rep(t,3){ if(k[t] == 0){ if(q != -1 && q != s[t]) ans = 0; q = s[t]; } else ans *= Modint(2).pow(k[t]-1); } if(q == -1) ans *= 2; cout << ans.val() << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); testcase(); return 0; }