Submission #1336793
Source Code Expand
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;
const int N = 300 + 10;
int64 dp[N][N][N];
void add(int64& x, int64 y) {
x = (x + y) % MOD;
}
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < m; ++i) {
for (int j = 1; j <= i + 1 && j <= n; ++j) {
for (int k = 1; k <= j; ++k) {
if (i == 0) dp[i][j][k] = 1;
add(dp[i + 1][j + 1][k], dp[i][j][k] * (n - j) % MOD);
add(dp[i + 1][j][j], dp[i][j][k] * k % MOD);
add(dp[i + 1][j][k], dp[i][j][k] * (j - k) % MOD);
}
}
}
printf("%lld\n", dp[m][n][n]);
return 0;
}
Submission Info
Submission Time
2017-06-08 20:42:08+0900
Task
F - Road of the King
User
cuiaoxiang
Language
C++14 (GCC 5.4.1)
Score
1000
Code Size
1508 Byte
Status
AC
Exec Time
89 ms
Memory
225536 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:50:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
^
Judge Result
Set Name
sample
all
Score / Max Score
0 / 0
1000 / 1000
Status
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
44 ms
223488 KB
01-04.txt
AC
1 ms
256 KB
01-05.txt
AC
44 ms
223488 KB
01-06.txt
AC
54 ms
225536 KB
01-07.txt
AC
88 ms
223488 KB
01-08.txt
AC
89 ms
225536 KB
01-09.txt
AC
89 ms
225536 KB
01-10.txt
AC
89 ms
225536 KB
sample-01.txt
AC
2 ms
2304 KB
sample-02.txt
AC
67 ms
225536 KB
sample-03.txt
AC
28 ms
112896 KB