Submission #10059800


Source Code Expand

#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const int MOD = 1e9 + 7;

long long inq(long long a, long long b)
{
    if (b == 0) return 1;
    long long l = inq(a, b / 2);
    if (b % 2) return l * l % MOD * a % MOD;
    return l * l % MOD;
}

long long n0, m0;
long long dp[310][310][310];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n0 >> m0;
    dp[0][1][1] = 1;
    for (int len = 0; len < m0; len++)
    {
        for (int i = 0; i <= n0; i++)
        {
            for (int j = 0; j <= i; j++)
            {
                dp[len + 1][i + 1][j] = (dp[len + 1][i + 1][j] + dp[len][i][j] * (n0 - i)) % MOD;
                dp[len + 1][i][j] = (dp[len + 1][i][j] + dp[len][i][j] * (i - j)) % MOD;
                dp[len + 1][i][i] = (dp[len + 1][i][i] + dp[len][i][j] * j) % MOD;
            }
        }
    }
    cout << dp[m0][n0][n0];
}

Submission Info

Submission Time
Task F - Road of the King
User IgorI
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 2487 Byte
Status AC
Exec Time 126 ms
Memory 226816 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 1 ms 256 KB
01-03.txt AC 45 ms 223488 KB
01-04.txt AC 2 ms 1024 KB
01-05.txt AC 44 ms 223616 KB
01-06.txt AC 52 ms 226048 KB
01-07.txt AC 120 ms 224768 KB
01-08.txt AC 125 ms 226816 KB
01-09.txt AC 126 ms 226816 KB
01-10.txt AC 126 ms 226816 KB
sample-01.txt AC 2 ms 2304 KB
sample-02.txt AC 66 ms 226304 KB
sample-03.txt AC 64 ms 114176 KB