結果
問題 |
No.2838 Diagonals
|
ユーザー |
![]() |
提出日時 | 2024-08-10 07:12:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 606 bytes |
コンパイル時間 | 2,155 ms |
コンパイル使用メモリ | 201,268 KB |
最終ジャッジ日時 | 2025-02-23 22:19:17 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/modint> #include<atcoder/dsu> using namespace std; using mint=atcoder::modint998244353; int H,W; string S[505]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>H>>W; atcoder::dsu uf(H*W); mint ans=1; for(int i=0;i<H;i++) { cin>>S[i]; for(int j=0;j<W;j++)if(S[i][j]=='#') { ans*=(i&&j&&uf.same((i-1)*W+j,i*W+(j-1))?2:4); if(i&&S[i-1][j]=='#')uf.merge(i*W+j,(i-1)*W+j); if(j&&S[i][j-1]=='#')uf.merge(i*W+j,i*W+(j-1)); } } cout<<ans.val()<<endl; }