Submission #2853402


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll dp[301][301][301];
ll n, m;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	dp[0][1][1] = 1;
	REP(i,m + 1) REP(j,n + 1) REP(k,n + 1) {
		dp[i][j][k] %= MOD;
		if(i < m) {
			dp[i + 1][j][j] += k * dp[i][j][k];
			dp[i + 1][j][k] += (j - k) * dp[i][j][k];
			if(j < n) dp[i + 1][j + 1][k] += (n - j) * dp[i][j][k];
		}
	}
	cout << dp[m][n][n] << endl;
	return 0;
}

Submission Info

Submission Time
Task F - Road of the King
User gazelle
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 881 Byte
Status AC
Exec Time 142 ms
Memory 213376 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 42 ms 211200 KB
01-04.txt AC 2 ms 1664 KB
01-05.txt AC 42 ms 211328 KB
01-06.txt AC 51 ms 211840 KB
01-07.txt AC 136 ms 213248 KB
01-08.txt AC 141 ms 213248 KB
01-09.txt AC 142 ms 213248 KB
01-10.txt AC 142 ms 213376 KB
sample-01.txt AC 2 ms 2304 KB
sample-02.txt AC 68 ms 212224 KB
sample-03.txt AC 73 ms 108800 KB