#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define MP make_pair
#define pb push_back
#define F first
#define S second
#define REP(i,a,b) for(int i=a; i<b; i++)
#define pii pair<int,int>
const int MX=2e2+3, mod=1e9+7;
int n, dp[MX][2];
map <int,int> mp;
int32_t main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
REP(i,0,n){
memset(dp, 0, sizeof dp);
int cnt;
cin>>cnt;
if(cnt==1 && mp.find(1)!=mp.end()) mp[1]--, cnt++;
mp[cnt]++;
int flg=0, cur=0, lst=0;
for(auto u:mp){
if(u.S && mp[u.F+1]) mp[u.F]--, mp[u.F+1]--, mp[u.F+2]++;
if(mp[u.F]>1) flg=1;
}
if(flg){
cout<<0<<endl;
continue;
}
dp[cur++][1]=1;
for(auto u:mp) if(u.S){
cnt=u.F-lst;
if(cnt%2==0){
dp[cur][1]=(dp[cur-1][0]+dp[cur-1][1])%mod;
dp[cur][0]=(dp[cur-1][0]*(cnt/2)%mod+dp[cur-1][1]*(cnt/2-1)%mod)%mod;
}
else{
dp[cur][0]=(dp[cur-1][0]+dp[cur-1][1])*(cnt/2)%mod;
dp[cur][1]=(dp[cur-1][0]+dp[cur-1][1])%mod;
}
cur++;
lst=u.F;
}
cout<<(dp[cur-1][0]+dp[cur-1][1])%mod<<endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Runtime error |
11 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |