Submission #991954


Source Code Expand

#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
long long dp[310][310][310];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(a>b){
		printf("0\n");
		return 0;
	}
	dp[0][0][1]=1;
	for(int i=0;i<b;i++){
		for(int j=0;j<=a;j++){
			for(int k=0;k<=a;k++){
				if(!dp[i][j][k])continue;
				dp[i+1][j+1][k]=(dp[i+1][j+1][k]+dp[i][j][k]*(a-j-k))%mod;
				dp[i+1][0][j+k]=(dp[i+1][0][j+k]+dp[i][j][k]*k)%mod;
				dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k]*(j))%mod;
			}
		}
	}
	printf("%lld\n",dp[b][0][a]);
}

Submission Info

Submission Time
Task F - Road of the King
User tozangezan
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 560 Byte
Status AC
Exec Time 398 ms
Memory 110720 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:7:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  int a,b;scanf("%d%d",&a,&b);
                             ^

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 6 ms 2816 KB
01-04.txt AC 1 ms 128 KB
01-05.txt AC 16 ms 8576 KB
01-06.txt AC 124 ms 56576 KB
01-07.txt AC 390 ms 109824 KB
01-08.txt AC 398 ms 110720 KB
01-09.txt AC 372 ms 110720 KB
01-10.txt AC 372 ms 110720 KB
sample-01.txt AC 1 ms 128 KB
sample-02.txt AC 216 ms 83328 KB
sample-03.txt AC 1 ms 128 KB