Submission #226200

# Submission time Handle Problem Language Result Execution time Memory
226200 2020-04-22T20:10:06 Z DS007 Asceticism (JOI18_asceticism) C++14
49 / 100
600 ms 98552 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int mod = 1e9 + 7;
map<pair<int, int>, int> dp;
int n, k;

int calc(int i, int j) {
    if (i < j || j == 0)
        return 0;
    else if (dp[{i, j}])
        return dp[{i, j}];
    else if (i == j)
        return dp[{i, j}] = 1;
    return dp[{i, j}] = (j * calc(i - 1, j) + (i - j + 1) * calc(i - 1, j - 1)) % mod;
}

void solveTestCase() {
    cin >> n >> k;
    cout << calc(n, k);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int test = 1;
    // cin >> test;
    for (int i = 1; i <= test; i++)
        solveTestCase();
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 14 ms 1664 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 6 ms 640 KB Output is correct
18 Correct 11 ms 1408 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 14 ms 1664 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 6 ms 640 KB Output is correct
18 Correct 11 ms 1408 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 5 ms 512 KB Output is correct
23 Correct 155 ms 15992 KB Output is correct
24 Correct 168 ms 16120 KB Output is correct
25 Correct 23 ms 3320 KB Output is correct
26 Correct 5 ms 640 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 19 ms 2688 KB Output is correct
29 Correct 8 ms 896 KB Output is correct
30 Correct 16 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 14 ms 1664 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 6 ms 640 KB Output is correct
18 Correct 11 ms 1408 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 5 ms 512 KB Output is correct
23 Correct 155 ms 15992 KB Output is correct
24 Correct 168 ms 16120 KB Output is correct
25 Correct 23 ms 3320 KB Output is correct
26 Correct 5 ms 640 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 19 ms 2688 KB Output is correct
29 Correct 8 ms 896 KB Output is correct
30 Correct 16 ms 2304 KB Output is correct
31 Correct 47 ms 16000 KB Output is correct
32 Correct 277 ms 41084 KB Output is correct
33 Execution timed out 1102 ms 98552 KB Time limit exceeded
34 Halted 0 ms 0 KB -