이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=400+10;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e13;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
int t[N];
ll nw[N][N],dp[N][N][2];
void solve(){
int n;
cin>>n;
nw[0][0]=1;
for(int i=1;i<=n;i++){
nw[i][0]=1;
for(int j=1;j<=i;j++) (nw[i][j]=nw[i-1][j]+nw[i-1][j-1])%=mod;
}
dp[0][0][0]=1;
for(int i=1;i<=n;i++){
dp[i][0][0]=1;
for(int j=1;j<=n;j++){
for(int k=0;k<=j;k++){
ll curr=nw[j][k];
if(k==i){
(dp[i][j][1]+=dp[i-1][j-k][0]*curr+dp[i-1][j-k][1]*curr)%=mod;
continue;
}
(dp[i][j][1]+=dp[i-1][j-k][1]*curr)%=mod;
(dp[i][j][0]+=dp[i-1][j-k][0]*curr)%=mod;
}
}
}
cout<<dp[n][n][1]<<"\n";
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0);
int tt=1;
while(tt--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |