Submission #1228473
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
const int mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;
int n,m;
ll dp[305][305][305];
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n >> m;
dp[0][1][1]=1;
rep2(i,1,m+1)rep2(j,1,n+1)rep2(k,1,j+1){
if (j!=n) dp[i][j+1][k]+=(dp[i-1][j][k]*(n-j))%mod;
dp[i][j][k]+=(dp[i-1][j][k]*(j-k))%mod;
dp[i][j][j]+=(dp[i-1][j][k]*k)%mod;
}
cout << dp[m][n][n]%mod << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
F - Road of the King |
User |
roto_37 |
Language |
C++14 (GCC 5.4.1) |
Score |
1000 |
Code Size |
1126 Byte |
Status |
AC |
Exec Time |
113 ms |
Memory |
218624 KB |
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 |
43 ms |
217344 KB |
01-04.txt |
AC |
2 ms |
1024 KB |
01-05.txt |
AC |
43 ms |
217344 KB |
01-06.txt |
AC |
49 ms |
217728 KB |
01-07.txt |
AC |
108 ms |
218624 KB |
01-08.txt |
AC |
112 ms |
218624 KB |
01-09.txt |
AC |
112 ms |
218624 KB |
01-10.txt |
AC |
113 ms |
218624 KB |
sample-01.txt |
AC |
2 ms |
2304 KB |
sample-02.txt |
AC |
61 ms |
218112 KB |
sample-03.txt |
AC |
57 ms |
110080 KB |