Submission #1846760
Source Code Expand
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
#define MOD 1000000007
using namespace std;
typedef long long ll;
int n,m;
int dp[302][302][302];
int f(int m, int k, int b){
if(dp[m][k][b]>=0)return dp[m][k][b];
int r=0;
if(m==0)r=!k&&!b;
else {
r=(1LL*(n-k)*f(m-1,k-b,0))%MOD;
r+=(1LL*b*f(m-1,k,b))%MOD;r%=MOD;
if(k-b){r+=(1LL*(k-b)*f(m-1,k,b+1))%MOD;r%=MOD;}
}
return dp[m][k][b]=r;
}
int main(){
scanf("%d%d",&n,&m);
memset(dp,-1,sizeof(dp));
printf("%d\n",f(m,n-1,0));
return 0;
}
Submission Info
Submission Time
2017-12-10 07:57:56+0900
Task
F - Road of the King
User
mjhun
Language
C++14 (GCC 5.4.1)
Score
1000
Code Size
842 Byte
Status
AC
Exec Time
155 ms
Memory
107904 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:35:21: 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
28 ms
107776 KB
01-02.txt
AC
28 ms
107776 KB
01-03.txt
AC
28 ms
107904 KB
01-04.txt
AC
28 ms
107776 KB
01-05.txt
AC
28 ms
107904 KB
01-06.txt
AC
54 ms
107904 KB
01-07.txt
AC
153 ms
107904 KB
01-08.txt
AC
155 ms
107904 KB
01-09.txt
AC
155 ms
107904 KB
01-10.txt
AC
155 ms
107904 KB
sample-01.txt
AC
28 ms
107776 KB
sample-02.txt
AC
91 ms
107904 KB
sample-03.txt
AC
44 ms
107904 KB