Submission #555768

# Submission time Handle Problem Language Result Execution time Memory
555768 2022-05-01T13:51:02 Z new_acc Zapina (COCI20_zapina) C++14
110 / 110
160 ms 3684 KB
#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
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 71 ms 2944 KB Output is correct
18 Correct 1 ms 724 KB Output is correct
19 Correct 15 ms 1876 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 95 ms 3120 KB Output is correct
22 Correct 12 ms 1688 KB Output is correct
23 Correct 2 ms 852 KB Output is correct
24 Correct 21 ms 2012 KB Output is correct
25 Correct 14 ms 1808 KB Output is correct
26 Correct 31 ms 2132 KB Output is correct
27 Correct 137 ms 3476 KB Output is correct
28 Correct 133 ms 3488 KB Output is correct
29 Correct 150 ms 3500 KB Output is correct
30 Correct 135 ms 3604 KB Output is correct
31 Correct 142 ms 3620 KB Output is correct
32 Correct 140 ms 3612 KB Output is correct
33 Correct 139 ms 3600 KB Output is correct
34 Correct 143 ms 3564 KB Output is correct
35 Correct 149 ms 3640 KB Output is correct
36 Correct 154 ms 3660 KB Output is correct
37 Correct 160 ms 3684 KB Output is correct