比赛 4043级2023省选模拟赛4 评测结果 AAAAAAAAAAAAAAAAAAAAA
题目名称 Moo Route 最终得分 100
用户昵称 op_组撒头屯 运行时间 0.577 s
代码语言 C++ 内存使用 26.33 MiB
提交时间 2023-03-27 10:07:34
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define si set<int>
#define unsi unordered_set<int>
#define qi queue<int>
#define sti stack<int>
#define pqi priority_queue<int>
#define mii map<int,int>
#define unmii unordered_map<int,int>
#define fi first
#define se second
#define pb push_back
#define clr(f,n) memset(f,0,sizeof(int)*(n))
#define cpy(f,g,n) memcpy(f,g,sizeof(int)*(n))
const int N=100000+5;
const ll mod=1000000007;
int n,m=1000000;
int a[N],tot[N];
map<int,int>mp[N];
map<int,int>::iterator it;
ll fac[10*N],inv[10*N];
ll fst(ll x,ll y){
    ll ans=1;
    while(y){
        if (y&1)ans=ans*x%mod;
        x=x*x%mod;y>>=1;
    }return ans;
}
ll C(int x,int y){
    return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main(){
	freopen ("moorouteg.in","r",stdin);
	freopen ("moorouteg.out","w",stdout);
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
	    scanf("%d",&a[i]);
	    if (a[i]&1){
	        printf("0\n");return 0;
        }
    }
    fac[0]=1;
    for (int i=1;i<=m;i++)fac[i]=fac[i-1]*i%mod;
    inv[m]=fst(fac[m],mod-2);
    for (int i=m-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    ll ans=1;
	for (int i=1;i<=n;i++){
	    if (a[i-1]&&a[i]>a[i-1])(ans*=C(a[i]/2-1,a[i-1]/2-1))%=mod;
	    if (a[i+1]&&a[i]>a[i+1])(ans*=C(a[i]/2,a[i+1]/2))%=mod;
    }printf("%lld\n",ans);
}