結果

問題 No.2605 Pickup Parentheses
ユーザー 沙耶花沙耶花
提出日時 2024-01-12 22:12:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,386 bytes
コンパイル時間 5,162 ms
コンパイル使用メモリ 280,528 KB
実行使用メモリ 17,408 KB
最終ジャッジ日時 2024-01-12 22:12:43
合計ジャッジ時間 11,094 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
11,776 KB
testcase_01 AC 22 ms
11,776 KB
testcase_02 AC 22 ms
11,776 KB
testcase_03 AC 23 ms
11,776 KB
testcase_04 AC 22 ms
11,904 KB
testcase_05 AC 23 ms
11,904 KB
testcase_06 AC 23 ms
11,904 KB
testcase_07 AC 23 ms
11,904 KB
testcase_08 AC 24 ms
11,904 KB
testcase_09 AC 23 ms
11,776 KB
testcase_10 AC 23 ms
11,904 KB
testcase_11 AC 23 ms
11,776 KB
testcase_12 AC 22 ms
11,776 KB
testcase_13 AC 22 ms
11,776 KB
testcase_14 AC 22 ms
11,776 KB
testcase_15 AC 22 ms
11,776 KB
testcase_16 AC 22 ms
11,776 KB
testcase_17 AC 22 ms
11,776 KB
testcase_18 AC 98 ms
14,032 KB
testcase_19 AC 60 ms
12,872 KB
testcase_20 AC 30 ms
12,032 KB
testcase_21 AC 26 ms
12,032 KB
testcase_22 AC 23 ms
11,904 KB
testcase_23 AC 97 ms
13,880 KB
testcase_24 AC 28 ms
12,032 KB
testcase_25 AC 119 ms
14,204 KB
testcase_26 AC 127 ms
14,388 KB
testcase_27 AC 89 ms
13,784 KB
testcase_28 WA -
testcase_29 AC 32 ms
12,032 KB
testcase_30 AC 48 ms
12,544 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 80 ms
13,176 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 66 ms
12,896 KB
testcase_38 AC 43 ms
12,672 KB
testcase_39 AC 28 ms
11,904 KB
testcase_40 AC 69 ms
13,364 KB
testcase_41 AC 69 ms
13,416 KB
testcase_42 AC 85 ms
13,660 KB
testcase_43 AC 35 ms
12,288 KB
testcase_44 AC 34 ms
12,288 KB
testcase_45 AC 22 ms
11,776 KB
testcase_46 AC 27 ms
11,904 KB
testcase_47 AC 22 ms
11,776 KB
testcase_48 AC 23 ms
11,904 KB
testcase_49 AC 59 ms
12,868 KB
testcase_50 AC 38 ms
12,160 KB
testcase_51 WA -
testcase_52 AC 44 ms
12,556 KB
testcase_53 AC 52 ms
12,784 KB
testcase_54 AC 37 ms
12,288 KB
testcase_55 AC 45 ms
12,544 KB
testcase_56 AC 27 ms
11,904 KB
testcase_57 WA -
testcase_58 AC 242 ms
17,408 KB
testcase_59 AC 100 ms
13,972 KB
testcase_60 AC 121 ms
14,136 KB
testcase_61 AC 116 ms
14,172 KB
testcase_62 AC 130 ms
14,188 KB
testcase_63 AC 121 ms
14,440 KB
testcase_64 AC 143 ms
15,028 KB
testcase_65 AC 108 ms
14,324 KB
testcase_66 AC 204 ms
15,872 KB
testcase_67 AC 119 ms
14,352 KB
testcase_68 AC 22 ms
11,776 KB
testcase_69 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
struct combi{
	deque<mint> kaijou;
	deque<mint> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(kaijou[i-1]*i);
		}
		
		mint b=kaijou[n].inv();
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(kaijou_[0]*k);
		}
	}
	
	mint combination(int n,int r){
		if(r>n)return 0;
		mint a = kaijou[n]*kaijou_[r];
		a *= kaijou_[n-r];
		return a;
	}
	
	mint junretsu(int a,int b){
		mint x = kaijou_[a]*kaijou_[b];
		x *= kaijou[a+b];
		return x;
	}
	
	mint catalan(int n){
		return combination(2*n,n)/(n+1);
	}
	
};
combi C(1000000);

int main(){
	
	int n,m;
	cin>>n>>m;
	queue<vector<mint>> Q;
	rep(i,m){
		int l,r;
		cin>>l>>r;
		l--;
		int len = r-l;
		if(len%2)continue;
		len /= 2;
		vector<mint> t(len+1);
		t[0] = 1;
		t[len] = -C.catalan(len);
		Q.push(t);
	}
	Q.push({1});
	while(Q.size()>=2){
		vector<mint> a = Q.front();
		Q.pop();
		auto b = Q.front();
		Q.pop();
		Q.push(convolution(a,b));
	}
	mint ans = 0;
	n /= 2;
	rep(i,Q.front().size()){
		mint t = Q.front()[i];
		t *= C.catalan(n-i);
		ans += t;
	}
	cout<<ans.val()<<endl;
	
	return 0;
}
0