結果
問題 | No.2291 Union Find Estimate |
ユーザー |
|
提出日時 | 2023-05-05 21:28:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 183 ms / 2,000 ms |
コード長 | 690 bytes |
コンパイル時間 | 941 ms |
コンパイル使用メモリ | 81,852 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-11-23 06:03:52 |
合計ジャッジ時間 | 2,137 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include<iostream>#include<atcoder/dsu>using namespace std;int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int N,M;cin>>N>>M;atcoder::dsu uf(N+10);for(;M--;){string Q;cin>>Q;vector<int>prv(26,-1);for(int i=0;i<N;i++){if(Q[i]=='?');else if(Q[i]>='0'&&Q[i]<='9'){uf.merge(i,N+Q[i]-'0');}else{int c=Q[i]-'a';if(prv[c]!=-1)uf.merge(prv[c],i);prv[c]=i;}}int ans=1;const int mod=998244353;for(vector<int>g:uf.groups()){int ex=0;for(int v:g)if(v>=N)ex|=1<<v-N;if(ex){if(__builtin_popcount(ex)>1)ans=0;}else{ans=ans*10LL%mod;}}cout<<ans<<"\n";}}