結果

問題 No.1873 Bracket Swapping
ユーザー tailstails
提出日時 2022-03-20 23:01:24
言語 cLay
(20240104-1)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 566 bytes
コンパイル時間 5,992 ms
コンパイル使用メモリ 186,056 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 16:13:27
合計ジャッジ時間 9,113 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 14 ms
5,376 KB
testcase_04 AC 6 ms
5,376 KB
testcase_05 AC 7 ms
5,376 KB
testcase_06 AC 57 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 104 ms
5,376 KB
testcase_09 AC 104 ms
5,376 KB
testcase_10 AC 79 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 42 ms
5,376 KB
testcase_13 AC 35 ms
5,376 KB
testcase_14 AC 105 ms
5,376 KB
testcase_15 AC 23 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 54 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 5 ms
5,376 KB
testcase_20 AC 89 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 9 ms
5,376 KB
testcase_23 RE -
testcase_24 AC 184 ms
5,376 KB
testcase_25 RE -
testcase_26 AC 54 ms
5,376 KB
testcase_27 AC 76 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define MD 998244353

string@s;
ll@k,n=s.size()/2;

Matrix<Mint> m(n+1,n+1);
rep(y,n+1){
	rep(x,n+1){
		m[y][x]=
			y==x-1 ? x*x:
			y==x ? n*(n*2-1)-(n-x)*(n-x)-x*x:
			y==x+1 ? (n-x)*(n-x):
			0;
	}
}
m**=k;

Mint d[102][101];
d[1][1]=1;
rep(i,1,n*2){
	if(s[i]=='('){
		rrep(j,1,n+2){
			rrep(k,i/2+1,min(n+1,i+2)){
				d[j][k]=d[j-1][k]+d[j][k-1];
			}
			d[j][i/2]=0;
		}
	}else{
		rrep(j,1,n+2){
			rrep(k,i/2+1,min(n+2,i+2)){
				d[j][k]+=d[j][k-1];
			}
			d[j][i/2]=0;
		}
	}
}

Comb<Mint>c;
Mint z=0;
rep(i,n+1){
	z+=m[i][0]/c.C(n,i)**2*d[i+1][n];
}
wt(z);
0