結果

問題 No.2605 Pickup Parentheses
ユーザー inksamuraiinksamurai
提出日時 2024-01-13 03:19:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,600 bytes
コンパイル時間 5,214 ms
コンパイル使用メモリ 271,760 KB
実行使用メモリ 814,528 KB
最終ジャッジ日時 2024-01-13 03:19:34
合計ジャッジ時間 10,434 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,676 KB
testcase_01 AC 7 ms
6,676 KB
testcase_02 AC 8 ms
6,676 KB
testcase_03 AC 8 ms
6,720 KB
testcase_04 AC 7 ms
6,720 KB
testcase_05 AC 7 ms
6,720 KB
testcase_06 AC 8 ms
6,720 KB
testcase_07 AC 8 ms
6,720 KB
testcase_08 AC 9 ms
6,720 KB
testcase_09 AC 7 ms
6,676 KB
testcase_10 AC 8 ms
6,720 KB
testcase_11 AC 8 ms
6,720 KB
testcase_12 AC 7 ms
6,676 KB
testcase_13 AC 7 ms
6,676 KB
testcase_14 AC 7 ms
6,676 KB
testcase_15 AC 7 ms
6,720 KB
testcase_16 AC 7 ms
6,676 KB
testcase_17 AC 7 ms
6,676 KB
testcase_18 AC 71 ms
8,832 KB
testcase_19 AC 38 ms
7,488 KB
testcase_20 AC 13 ms
6,976 KB
testcase_21 AC 11 ms
6,848 KB
testcase_22 AC 8 ms
6,720 KB
testcase_23 AC 73 ms
8,844 KB
testcase_24 AC 13 ms
6,976 KB
testcase_25 AC 82 ms
8,856 KB
testcase_26 AC 86 ms
8,924 KB
testcase_27 AC 71 ms
8,828 KB
testcase_28 AC 11 ms
6,848 KB
testcase_29 AC 14 ms
6,976 KB
testcase_30 AC 25 ms
7,104 KB
testcase_31 AC 8 ms
6,720 KB
testcase_32 AC 7 ms
6,676 KB
testcase_33 AC 46 ms
7,828 KB
testcase_34 AC 10 ms
6,848 KB
testcase_35 AC 7 ms
6,676 KB
testcase_36 AC 10 ms
6,720 KB
testcase_37 AC 39 ms
7,616 KB
testcase_38 AC 21 ms
7,360 KB
testcase_39 AC 11 ms
6,848 KB
testcase_40 AC 42 ms
8,536 KB
testcase_41 AC 38 ms
8,668 KB
testcase_42 AC 53 ms
8,828 KB
testcase_43 AC 15 ms
6,976 KB
testcase_44 AC 15 ms
6,912 KB
testcase_45 AC 7 ms
6,676 KB
testcase_46 AC 9 ms
6,848 KB
testcase_47 AC 7 ms
6,676 KB
testcase_48 AC 7 ms
6,676 KB
testcase_49 AC 32 ms
7,616 KB
testcase_50 AC 17 ms
6,976 KB
testcase_51 AC 7 ms
6,676 KB
testcase_52 AC 23 ms
7,320 KB
testcase_53 AC 31 ms
7,616 KB
testcase_54 AC 16 ms
6,848 KB
testcase_55 AC 23 ms
7,464 KB
testcase_56 AC 10 ms
6,848 KB
testcase_57 AC 7 ms
6,676 KB
testcase_58 AC 109 ms
9,492 KB
testcase_59 AC 75 ms
8,796 KB
testcase_60 AC 94 ms
8,788 KB
testcase_61 AC 91 ms
8,648 KB
testcase_62 AC 94 ms
8,632 KB
testcase_63 AC 101 ms
8,780 KB
testcase_64 AC 102 ms
8,972 KB
testcase_65 AC 78 ms
8,836 KB
testcase_66 AC 121 ms
9,236 KB
testcase_67 AC 88 ms
8,612 KB
testcase_68 MLE -
testcase_69 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _4aNWZeC ios::sync_with_stdio(0),cin.tie(0)
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}

using namespace atcoder;

using mint=modint998244353;

const int _n=4e5;

mint fact[_n+11],invfact[_n+11];

void initfact(){
	fact[0]=1;
	rng(i,1,_n){
		fact[i]=fact[i-1]*mint(i);
	}
	invfact[_n-1]=fact[_n-1].inv();
	per(i,_n-1){
		invfact[i]=invfact[i+1]*mint(i+1);
	}
}

mint cnk(ll k,ll n){
	return k>n?0:fact[n]*invfact[k]*invfact[n-k];
}

mint f(int n){
	return cnk(n,2*n)-cnk(n+1,2*n);
}

void slv(){
	int n,q;
	cin>>n>>q;
	vi xs;
	rep(i,q){
		int l,r;
		cin>>l>>r;
		l-=1;
		if((r-l)%2==0){
			xs.pb(r-l);
		}
	}
	if(n%2){
		print(0);
		return;
	}
	int si=sz(xs);
	using vm=vec(mint);
	auto rec=[&](auto self,int l,int r)->vm{
		if(l==r){
			vm res(xs[l]/2+1);
			res[0]=1;
			res[xs[l]/2]=-f(xs[l]/2);
			return res;
		}
		int m=(l+r)/2;
		return convolution(self(self,l,m),self(self,m+1,r));
	};
	vm c=rec(rec,0,si-1);
	mint ans=0;
	for(int i=0;i<sz(c);i++){
		if(i*2>n) break;
		// print(i,c[i].val());
		ans+=f((n-i*2)/2)*c[i];
	}
	// print(f(xs[0]/2).val());
	print(ans.val());
}

signed main(){
_4aNWZeC;
	initfact();
	slv();
}
0