結果

問題 No.1873 Bracket Swapping
ユーザー tailstails
提出日時 2022-03-20 23:28:45
言語 cLay
(20240104-1)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 578 bytes
コンパイル時間 5,699 ms
コンパイル使用メモリ 186,708 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 16:39:20
合計ジャッジ時間 7,832 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 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 6 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 105 ms
5,376 KB
testcase_10 AC 81 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 44 ms
5,376 KB
testcase_13 AC 35 ms
5,376 KB
testcase_14 AC 103 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 88 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 8 ms
5,376 KB
testcase_23 AC 141 ms
5,376 KB
testcase_24 AC 92 ms
5,376 KB
testcase_25 AC 108 ms
5,376 KB
testcase_26 AC 55 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;
long t=1;
rep(i,1,n*2){
	if(s[i]=='('){
		t+=1;
		rrep(j,t){
			rrep(k,i/2,min(n,i+1)){
				d[j+1][k+1]=d[j][k+1]+d[j+1][k];
			}
			d[j+1][i/2]=0;
		}
	}else{
		rrep(j,t){
			rrep(k,i/2,min(n,i+1)){
				d[j+1][k+1]+=d[j+1][k];
			}
			d[j+1][i/2]=0;
		}
	}
}

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