本文主要是介绍Codeforces Round 940 (Div. 2) C. How Does the Rook Move?,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
//dp删除后,可以堆成新的N*N.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
const int n=1e6+11;
int a,b,c,d[n],l,r;
signed main()
{ios::sync_with_stdio(false);cin>>a;d[1]=1;d[0]=1;for(int i=2;i<=3e5;i++){d[i]=(d[i-1]+(d[i-2]*(i-1)*2)%mod)%mod;}while(a--){cin>>b>>c;for(int i=1;i<=c;i++){cin>>l>>r;if(l==r){b--;}else{b-=2;}}cout<<d[b]<<endl;}
}
这篇关于Codeforces Round 940 (Div. 2) C. How Does the Rook Move?的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!