結果

問題 No.2291 Union Find Estimate
ユーザー tailstails
提出日時 2023-05-05 22:27:44
言語 cLay
(20240104-1)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 3,935 ms
コンパイル使用メモリ 177,088 KB
実行使用メモリ 6,268 KB
最終ジャッジ日時 2024-05-02 17:11:19
合計ジャッジ時間 4,331 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 10 ms
5,376 KB
testcase_03 AC 27 ms
6,268 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 15 ms
5,376 KB
testcase_16 AC 5 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define MD 998244353
ll@w,@h;
unionFind u('m',w,1);
Mint z=Mint(10)**w;
ll b[w];
rep(j,w)b[j]=1023;
rep(h){
	string@q;
	ll a[26]{};
	rep(j,w){
		ll c=q[j];
		ll k=u(j);
		if(c>='0'&&c<='9'){
			c-='0';
			if(b[k]!=1<<c){
				z/=BIT_popcount(b[k]);
				b[k]&=1<<c;
				z*=BIT_popcount(b[k]);
			}
		}
		if(c>='a'&&c<='z'){
			c-='a';
			if(a[c]){
				ll d=u(a[c]-1);
				if(u(d,k)){
					z/=BIT_popcount(b[d]);
					if(b[d]!=b[k]){
						z/=BIT_popcount(b[k]);
						b[u(d)]=b[d]&b[k];
						z*=BIT_popcount(b[u(d)]);
					}
				}
			}else{
				a[c]=k+1;
			}
		}
	}
	wt(z);
}
0