Submission #706604

# Submission time Handle Problem Language Result Execution time Memory
706604 2023-03-07T06:33:21 Z YugiHacker Zapina (COCI20_zapina) C++14
110 / 110
253 ms 3292 KB
/*
	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

zapina.cpp:23:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   23 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1296 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1296 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1296 KB Output is correct
8 Correct 1 ms 1236 KB Output is correct
9 Correct 1 ms 1236 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1364 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 1 ms 1364 KB Output is correct
15 Correct 1 ms 1296 KB Output is correct
16 Correct 1 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1296 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1296 KB Output is correct
8 Correct 1 ms 1236 KB Output is correct
9 Correct 1 ms 1236 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1364 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 1 ms 1364 KB Output is correct
15 Correct 1 ms 1296 KB Output is correct
16 Correct 1 ms 1364 KB Output is correct
17 Correct 121 ms 2788 KB Output is correct
18 Correct 2 ms 1492 KB Output is correct
19 Correct 30 ms 2092 KB Output is correct
20 Correct 1 ms 1304 KB Output is correct
21 Correct 180 ms 2952 KB Output is correct
22 Correct 19 ms 2004 KB Output is correct
23 Correct 2 ms 1492 KB Output is correct
24 Correct 35 ms 2244 KB Output is correct
25 Correct 25 ms 2132 KB Output is correct
26 Correct 47 ms 2380 KB Output is correct
27 Correct 223 ms 3108 KB Output is correct
28 Correct 242 ms 3144 KB Output is correct
29 Correct 229 ms 3148 KB Output is correct
30 Correct 236 ms 3180 KB Output is correct
31 Correct 240 ms 3144 KB Output is correct
32 Correct 233 ms 3132 KB Output is correct
33 Correct 241 ms 3196 KB Output is correct
34 Correct 253 ms 3292 KB Output is correct
35 Correct 240 ms 3128 KB Output is correct
36 Correct 241 ms 3148 KB Output is correct
37 Correct 247 ms 3288 KB Output is correct