Submission #706604

#TimeUsernameProblemLanguageResultExecution timeMemory
706604YugiHackerZapina (COCI20_zapina)C++14
110 / 110
253 ms3292 KiB
/*
	www.youtube.com/YugiHackerChannel
	oj.vnoi.info/user/YugiHackerKhongCopCode
*/
#include<bits/stdc++.h>
#define el cout<<"\n"
#define f0(i,n) for(int i=0;i<n;++i)
#define f1(i,n) for(int i=1;i<=n;++i)
#define maxn 352
#define MOD 1000000007
using namespace std;
int n;
long long f[maxn][maxn][2];
//f[i][n][ok]: chon den nguoi thu i, da su dung n tasks, ok: da co nguoi thoa man chua
long long c[maxn][maxn];
long long C(int n, int k)
{
    if (n == k || k == 0) return 1;
    if (k>n) return 0;
    if (c[n][k] != -1) return c[n][k];
    return c[n][k] = (C(n-1, k) + C(n-1, k-1)) % MOD;
}
main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    memset(c, -1, sizeof c);
    cin >> n;
    f[0][0][0] = 1;
    for (int i=1; i<=n; i++)
    {
        for (int x=0; x<=n; x++)
        {
            for (int j=0; j<=x; j++)
            {
                if(j!=i) (f[i][x][0] += C(n-x+j, j) * f[i-1][x-j][0] % MOD) %= MOD;
                else (f[i][x][1] += C(n-x+j, j) * f[i-1][x-j][0] % MOD) %= MOD;

                (f[i][x][1] += C(n-x+j, j) * f[i-1][x-j][1] % MOD) %= MOD;
            }
        }
    }
    cout << f[n][n][1];
}

Compilation message (stderr)

zapina.cpp:23:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   23 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...