Submission #1834843


Source Code Expand

#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )

using namespace std;

const int N = 305, mod = 1e9 + 7;

int n, m;
long long dp[N][N][N];

main ()
{
    cin >> n >> m;
    dp[0][1][1] = 1;
    for (int i = 0; i <= m; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            for (int k = 0; k <= j; k++)
            {
                dp[i + 1][j + 1][k] += dp[i][j][k] * (n - j);
                dp[i + 1][j + 1][k] %= mod;

                dp[i + 1][j][k] += dp[i][j][k] * (j - k);
                dp[i + 1][j][k] %= mod;

                dp[i + 1][j][j] += dp[i][j][k] * k;
                dp[i + 1][j][j] %= mod;
            }
        }
    }
    cout << dp[m][n][n] << endl;
}

Submission Info

Submission Time
Task F - Road of the King
User vjudge2
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 1046 Byte
Status AC
Exec Time 125 ms
Memory 220672 KB

Judge Result

Set Name sample all
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 3
AC × 16
Set Name Test Cases
sample sample-01.txt, sample-02.txt, sample-03.txt
all sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01-01.txt AC 1 ms 256 KB
01-02.txt AC 2 ms 2304 KB
01-03.txt AC 43 ms 217344 KB
01-04.txt AC 3 ms 3584 KB
01-05.txt AC 43 ms 217344 KB
01-06.txt AC 50 ms 217728 KB
01-07.txt AC 119 ms 218624 KB
01-08.txt AC 124 ms 220672 KB
01-09.txt AC 125 ms 220672 KB
01-10.txt AC 125 ms 220672 KB
sample-01.txt AC 2 ms 2304 KB
sample-02.txt AC 64 ms 218112 KB
sample-03.txt AC 64 ms 110080 KB