結果
| 問題 |
No.2837 Flip Triomino
|
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2024-08-10 06:54:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 2,000 ms |
| コード長 | 665 bytes |
| コンパイル時間 | 2,005 ms |
| コンパイル使用メモリ | 195,860 KB |
| 最終ジャッジ日時 | 2025-02-23 22:19:09 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int H,W,cnt[3][2];
string S[505];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>H>>W;
for(int i=0;i<H;i++)
{
cin>>S[i];
for(int j=0;j<W;j++)
{
if(S[i][j]=='B')cnt[(i+j)%3][0]++;
if(S[i][j]=='?')cnt[(i+j)%3][1]++;
}
}
mint ans1=1,ans2=1;
for(int k=0;k<3;k++)ans1*=(cnt[k][1]==0?cnt[k][0]%2==0:mint::raw(2).pow(cnt[k][1]-1));
for(int k=0;k<3;k++)ans2*=(cnt[k][1]==0?cnt[k][0]%2==1:mint::raw(2).pow(cnt[k][1]-1));
cout<<(ans1+ans2).val()<<endl;
}
nonon