Submission #2853399


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[334][334][334];
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 0
Code Size 881 Byte
Status MLE
Exec Time 152 ms
Memory 264320 KB

Judge Result

Set Name sample all
Score / Max Score 0 / 0 0 / 1000
Status
AC × 2
MLE × 1
AC × 7
MLE × 9
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 MLE 51 ms 260352 KB
01-04.txt AC 3 ms 1792 KB
01-05.txt MLE 51 ms 260480 KB
01-06.txt MLE 61 ms 261120 KB
01-07.txt MLE 144 ms 262144 KB
01-08.txt MLE 150 ms 264320 KB
01-09.txt MLE 151 ms 264320 KB
01-10.txt MLE 152 ms 264320 KB
sample-01.txt AC 2 ms 2304 KB
sample-02.txt MLE 77 ms 261504 KB
sample-03.txt AC 77 ms 133376 KB