Submission #203815

# Submission time Handle Problem Language Result Execution time Memory
203815 2020-02-22T09:07:42 Z mayhoubsaleh Zapina (COCI20_zapina) C++14
110 / 110
405 ms 4088 KB
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define left 2*i+1
#define righ 2*i+2
#define mid (l+r)/2


using namespace std;
const ll mod=1e9+7;
ll n,dp[400][400][2],ch[400][400];

ll solve(ll st,ll pr,ll ok){
    if(st==n){
        if(pr==n)return ok;
        return 0;
    }
    ll &ans=dp[st][pr][ok];
    if(ans+1)return ans;
    ans=0;
    for(ll i=0;i+pr<=n;i++){
        if(st+1==i){
            ans=(ans+solve(st+1,pr+i,1)*ch[n-pr][i]%mod)%mod;
        }
        else
        ans=(ans+solve(st+1,pr+i,ok)*ch[n-pr][i]%mod)%mod;
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    memset(dp,-1,sizeof dp);

    for(ll i=0;i+25<400;i++){
        ch[i][0]=1;
        for(ll j=1;j<=i;j++){
            ch[i][j]=(ch[i-1][j]+ch[i-1][j-1])%mod;
        }
    }

    cout<<solve(0,0,0)<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4088 KB Output is correct
2 Correct 7 ms 3960 KB Output is correct
3 Correct 7 ms 3964 KB Output is correct
4 Correct 7 ms 4088 KB Output is correct
5 Correct 6 ms 3960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4088 KB Output is correct
2 Correct 7 ms 3960 KB Output is correct
3 Correct 7 ms 3964 KB Output is correct
4 Correct 7 ms 4088 KB Output is correct
5 Correct 6 ms 3960 KB Output is correct
6 Correct 7 ms 3964 KB Output is correct
7 Correct 7 ms 3960 KB Output is correct
8 Correct 8 ms 4088 KB Output is correct
9 Correct 7 ms 3960 KB Output is correct
10 Correct 7 ms 4088 KB Output is correct
11 Correct 7 ms 3960 KB Output is correct
12 Correct 7 ms 3960 KB Output is correct
13 Correct 7 ms 3960 KB Output is correct
14 Correct 7 ms 3960 KB Output is correct
15 Correct 7 ms 3960 KB Output is correct
16 Correct 6 ms 3960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4088 KB Output is correct
2 Correct 7 ms 3960 KB Output is correct
3 Correct 7 ms 3964 KB Output is correct
4 Correct 7 ms 4088 KB Output is correct
5 Correct 6 ms 3960 KB Output is correct
6 Correct 7 ms 3964 KB Output is correct
7 Correct 7 ms 3960 KB Output is correct
8 Correct 8 ms 4088 KB Output is correct
9 Correct 7 ms 3960 KB Output is correct
10 Correct 7 ms 4088 KB Output is correct
11 Correct 7 ms 3960 KB Output is correct
12 Correct 7 ms 3960 KB Output is correct
13 Correct 7 ms 3960 KB Output is correct
14 Correct 7 ms 3960 KB Output is correct
15 Correct 7 ms 3960 KB Output is correct
16 Correct 6 ms 3960 KB Output is correct
17 Correct 197 ms 4088 KB Output is correct
18 Correct 8 ms 4088 KB Output is correct
19 Correct 45 ms 3960 KB Output is correct
20 Correct 7 ms 4088 KB Output is correct
21 Correct 260 ms 4088 KB Output is correct
22 Correct 34 ms 4088 KB Output is correct
23 Correct 9 ms 3960 KB Output is correct
24 Correct 61 ms 4088 KB Output is correct
25 Correct 43 ms 3960 KB Output is correct
26 Correct 84 ms 4068 KB Output is correct
27 Correct 371 ms 4088 KB Output is correct
28 Correct 380 ms 3960 KB Output is correct
29 Correct 372 ms 4088 KB Output is correct
30 Correct 363 ms 3960 KB Output is correct
31 Correct 393 ms 4080 KB Output is correct
32 Correct 389 ms 4088 KB Output is correct
33 Correct 382 ms 4088 KB Output is correct
34 Correct 402 ms 4088 KB Output is correct
35 Correct 391 ms 4088 KB Output is correct
36 Correct 400 ms 4088 KB Output is correct
37 Correct 405 ms 4088 KB Output is correct