Submission #993374


Source Code Expand

#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

ll dp[301][301][301];

int main() {
	int N, M; cin >> N >> M;
	dp[1][0][0] = 1;
	rep(m, M)
		for (int i = 1; i <= N; i++)
			for (int j = 0; i + j <= N; j++) {
				ll x = dp[i][j][m];
				int k = N - i - j;
				dp[i + j][0][m + 1] = (dp[i + j][0][m + 1] + x * i) % MOD;
				dp[i][j + 1][m + 1] = (dp[i][j + 1][m + 1] + x * k) % MOD;
				dp[i][j][m + 1] = (dp[i][j][m + 1] + x * j) % MOD;
			}
	cout << dp[N][0][M] << endl;
}

Submission Info

Submission Time
Task F - Road of the King
User sugim48
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 1177 Byte
Status AC
Exec Time 838 ms
Memory 108288 KB

Judge Result

Set Name sample all
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 3
AC × 13
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
Case Name Status Exec Time Memory
01-01.txt AC 3 ms 256 KB
01-02.txt AC 2 ms 256 KB
01-03.txt AC 3 ms 256 KB
01-04.txt AC 193 ms 107648 KB
01-05.txt AC 3 ms 384 KB
01-06.txt AC 71 ms 10240 KB
01-07.txt AC 778 ms 101248 KB
01-08.txt AC 825 ms 106880 KB
01-09.txt AC 831 ms 107648 KB
01-10.txt AC 838 ms 108288 KB
sample-01.txt AC 3 ms 256 KB
sample-02.txt AC 197 ms 27776 KB
sample-03.txt AC 514 ms 107904 KB