Submission #994266


Source Code Expand

#include <cstdio>

long long dp[308][308];
long long dp2[308][308];
long long MOD=1000000007;
long long add(long long x,long long y) {
	x+=y;
	return x%MOD;
}
long long prod(long long x,long long y) {
	x*=y;
	return x%MOD;
}
int main() {
	int N,M;
	scanf("%d%d",&N,&M);
	dp[N-1][0]=1;
	for(int round=0;round<M;round++) {
		for(int i=0;i<=N;i++) {
			for(int j=0;j<=N;j++) dp2[i][j]=0;
		}
		for(int i=0;i<=N;i++) {
			for(int j=0;j<=i;j++) {
				dp2[i-j][0]=add(dp2[i-j][0],prod(dp[i][j],N-i));
				dp2[i][j]=add(dp2[i][j],prod(dp[i][j],j));
				if(i>j) dp2[i][j+1]=add(dp2[i][j+1],prod(dp[i][j],i-j));
			}
		}
		for(int i=0;i<=N;i++) {
			for(int j=0;j<=N;j++) dp[i][j]=dp2[i][j];
		}
	}
	printf("%lld\n",dp[0][0]);
	return 0;
}

Submission Info

Submission Time
Task F - Road of the King
User phidnight
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 766 Byte
Status AC
Exec Time 837 ms
Memory 1664 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16: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
AC × 3
AC × 13
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
Case Name Status Exec Time Memory
01-01.txt AC 1 ms 128 KB
01-02.txt AC 1 ms 128 KB
01-03.txt AC 1 ms 128 KB
01-04.txt AC 6 ms 1664 KB
01-05.txt AC 3 ms 256 KB
01-06.txt AC 78 ms 640 KB
01-07.txt AC 781 ms 1536 KB
01-08.txt AC 826 ms 1536 KB
01-09.txt AC 832 ms 1664 KB
01-10.txt AC 837 ms 1664 KB
sample-01.txt AC 1 ms 128 KB
sample-02.txt AC 215 ms 896 KB
sample-03.txt AC 418 ms 1664 KB