Submission #1632380


Source Code Expand

#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pii pair<int,int> 
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 305
using namespace std;
typedef long long ll;
int n,m,f[N][N][N];
inline void upd(int& a,int b){a=a+b>=dalao?a+b-dalao:a+b;}
int main(){
	cin>>n>>m,f[0][1][1]=1;
	for(int i=0;i<m;i++)for(int j=1;j<=n;j++)for(int k=1;k<=j;k++)if(f[i][j][k])
		upd(f[i+1][j+1][k],1ll*f[i][j][k]*(n-j)%dalao),
		upd(f[i+1][j][k],1ll*f[i][j][k]*(j-k)%dalao),
		upd(f[i+1][j][j],1ll*f[i][j][k]*k%dalao);
	printf("%d",f[m][n][n]);
	return 0;
}

Submission Info

Submission Time
Task F - Road of the King
User cdsfcesf
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 737 Byte
Status AC
Exec Time 63 ms
Memory 108800 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 22 ms 108800 KB
01-04.txt AC 1 ms 256 KB
01-05.txt AC 22 ms 108800 KB
01-06.txt AC 30 ms 108800 KB
01-07.txt AC 62 ms 108800 KB
01-08.txt AC 63 ms 108800 KB
01-09.txt AC 63 ms 108800 KB
01-10.txt AC 63 ms 108800 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 40 ms 108800 KB
sample-03.txt AC 21 ms 53504 KB