結果
| 問題 |
No.2837 Flip Triomino
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-09 21:40:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 733 bytes |
| コンパイル時間 | 474 ms |
| コンパイル使用メモリ | 68,440 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-08-09 21:41:00 |
| 合計ジャッジ時間 | 1,509 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include<iostream>
#include<cassert>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int N,M;
int n[3][3]={
{0,1,2},
{1,2,0},
{2,0,1}
};
int cnt[3];
int E[3];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>M;
for(int i=0;i<N;i++)
{
string S;cin>>S;
for(int j=0;j<M;j++)
{
int x=n[i%3][j%3];
if(S[j]=='?')cnt[x]++;
else if(S[j]=='B')E[x]=!E[x];
}
}
mint all=0;
{
mint ans=1;
for(int i=0;i<3;i++)
{
if(cnt[i]>0)ans*=mint(2).pow(cnt[i]-1);
else if(E[i]==1)ans=0;
}
all+=ans;
}
{
mint ans=1;
for(int i=0;i<3;i++)
{
if(cnt[i]>0)ans*=mint(2).pow(cnt[i]-1);
else if(E[i]==0)ans=0;
}
all+=ans;
}
cout<<all.val()<<endl;
}