Submission #290900

# Submission time Handle Problem Language Result Execution time Memory
290900 2020-09-04T14:26:15 Z blue Asceticism (JOI18_asceticism) C++11
0 / 100
1 ms 384 KB
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

//4 pts: N <= 10
/*
int main()
{
    int N, K;
    cin >> N >> K;

    vector<int> X(N);
    for(int i = 1; i <= N; i++) X[i-1] = i;

    int res = 0;
    int a;
    do
    {
        a = 1;
        for(int i = 1; i < N; i++) if(X[i-1] > X[i]) a++;
        if(a == K) res++;
    } while(next_permutation(X.begin(), X.end()));
    cout << res << '\n';
    return 0;
}
*/

/*
dp[i][j]
Order has sentences 1..i and can be read in j days
Sentence number i+1 can be inserted anywhere but the end of a day to create a new day.
i.e. dp[i+1][j] += dp[i][j] * j;
     dp[i+1][j+1] += dp[i][j] * (i - j + 1);
*/

long long mod = 1e9+7;

//20 pts: N <= 300
int main()
{
    long long N, K;
    cin >> N >> K;

    long long dp[N+1][K+1];
    dp[1][1] = 1;
    for(long long i = 2; i <= N; i++)
    {
        dp[i][1] = 1;
        for(long long j = 2; j < i; j++)
        {
            dp[i][j] = ((dp[i-1][j] * j) % mod + (dp[i-1][j-1] * (i - j + 1)) % mod) % mod;
        }
        dp[i][i] = 1;
    }
    for(long long i = N+1; i <= N; i++)
    {
        for(long long j = 1; j <= i; j++) cout << dp[i][j] << ' ';
        cout << '\n';
    }
    cout << dp[N][K] << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Runtime error 1 ms 384 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Runtime error 1 ms 384 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Runtime error 1 ms 384 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Runtime error 1 ms 384 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -